-
Notifications
You must be signed in to change notification settings - Fork 19
Add OAuth Authentication section to Webhooks Overview #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kavanpd
wants to merge
1
commit into
main
Choose a base branch
from
deveco-358-oauth-webhooks-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+68
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,71 @@ The `filter` of a webhook subscription determines which events will match and pr | |
|
|
||
| In the case of incident events, the different filter types will only produce webhooks for the incidents that are associated with the filter object. For example: a webhook subscription with a service filter would produce webhooks for all incidents belonging to the specified service. | ||
|
|
||
| ### OAuth Authentication | ||
|
|
||
| PagerDuty can authenticate webhook deliveries to your endpoint using the [OAuth 2.0 client credentials flow](https://datatracker.ietf.org/doc/html/rfc6749#section-4.4). When a webhook subscription is associated with an _OAuth client_, PagerDuty obtains an access token from your authorization server and includes it as a bearer token in the `Authorization` header of each webhook request. | ||
|
|
||
| #### Purpose and Use Cases | ||
|
|
||
| OAuth authentication is useful when your webhook destination requires token-based authentication rather than static credentials. Common use cases include: | ||
|
|
||
| - Delivering webhooks to platforms that require OAuth for inbound requests, such as ServiceNow | ||
| - Enterprise environments with security policies that prohibit static secrets (such as basic auth credentials in URLs or fixed custom headers) | ||
| - Endpoints that need the ability to revoke or rotate credentials centrally on their own authorization server | ||
|
|
||
| Compared to static authentication methods, OAuth provides automatic token refresh and retry behavior: if a delivery receives a `401 Unauthorized` response, PagerDuty refreshes the token and immediately retries. See [OAuth Authentication Retries](../../docs/webhooks/02-Behavior.md#oauth-authentication-retries) for complete retry behavior. | ||
|
|
||
| #### Creating an OAuth Client | ||
|
|
||
| Create an OAuth client using the OAuth Clients API (`POST /webhook_subscriptions/oauth_clients`) or from the Webhooks page in the PagerDuty web app. An OAuth client consists of: | ||
|
|
||
| | Field | Description | | ||
| | --------------- | -------------------------------------------------------------------------------------------- | | ||
| | `name` | A friendly name for the OAuth client. | | ||
| | `client_id` | The client ID issued by your OAuth authorization server. | | ||
| | `client_secret` | The client secret issued by your OAuth authorization server. Redacted in API responses. | | ||
| | `token_url` | The token endpoint on your authorization server that PagerDuty will request access tokens from. | | ||
| | `grant_type` | Must be `client_credentials`. | | ||
| | `scope` | Optional. Scopes to request from your authorization server, if it requires them. | | ||
|
|
||
| When an OAuth client is created or updated, PagerDuty validates the configuration by requesting an access token from the `token_url`. If a token cannot be obtained, the create or update request fails. Ensure your authorization server is reachable from the public internet and that the credentials are valid before creating the client. | ||
|
|
||
| #### Associating an OAuth Client with a Webhook Subscription | ||
|
|
||
| Reference the OAuth client by ID when creating or updating a webhook subscription: | ||
|
|
||
| ```json | ||
| { | ||
| "webhook_subscription": { | ||
| "delivery_method": { | ||
| "type": "http_delivery_method", | ||
| "url": "https://example.com/receive_a_pagerduty_webhook" | ||
| }, | ||
| "description": "Sends PagerDuty v3 webhook events with OAuth authentication.", | ||
| "events": ["incident.triggered", "incident.resolved"], | ||
| "filter": { | ||
| "id": "P393ZNQ", | ||
| "type": "service_reference" | ||
| }, | ||
| "oauth_client_id": "AGMEB7F7YJYELCPG4Y5YWMYGXE", | ||
| "type": "webhook_subscription" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| A single OAuth client may be used by multiple webhook subscriptions. Deleting an OAuth client removes the association from any webhook subscriptions using it. | ||
|
|
||
| #### Product Limits | ||
|
|
||
| Each account may have a maximum of **10 OAuth clients**. Requests to create additional clients beyond this limit return a `400` error with error code `2019`. | ||
|
|
||
| #### Permissions and Requirements | ||
|
|
||
| - Managing OAuth clients requires the same permissions as managing webhook subscriptions. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect. It requires admin or owner permissions. In contrast, lower tier users can manage webhook subscriptions belonging to their services. |
||
| - For [Scoped OAuth](https://developer.pagerduty.com/docs/oauth-functionality) API access, listing and reading OAuth clients requires the `webhook_subscriptions.read` scope; creating, updating, and deleting them requires the `webhook_subscriptions.write` scope. | ||
| - Only the `client_credentials` grant type is supported. | ||
| - Your authorization server must implement the token endpoint per [RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749). If the token response omits `token_type`, PagerDuty assumes `Bearer`. | ||
|
|
||
| ### More Details | ||
|
|
||
| Please see the full [Webhook Subscriptions API Reference](https://developer.pagerduty.com/api-reference/b3A6MjkyNDc4NA-create-a-webhook-subscription) for more details. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I see the point of adding this information here. It duplicates the authoritative source in the API reference and is just another place that can fall out of sync. I think we could link to the API reference here for the specific details about how the requests work. (Note that Claude can't read that link because it's a SPA, but may have more luck here ).