Authenticate webhooks with OAuth 2.0
When the system that receives your automation webhooks is protected by OAuth 2.0, Installer.com gets an access token from that system’s identity provider. Each webhook request carries the token. You enter the client credentials once, on the webhook endpoint, and every automation that sends to that endpoint uses them.
Installer.com uses the OAuth 2.0 client credentials grant, made for one system calling another without a person signing in. To set up the webhook automation itself, see Send webhooks from automations.
Choose how the receiving system checks a webhook
The Authentication setting on each webhook endpoint decides which credential Installer.com sends to the receiving system. To open the endpoint settings, open the automation and select the endpoint tag in Send payload to.
| Option | What Installer.com sends |
|---|---|
| None | No credential. |
| API key header | A fixed header the receiving system expects, such as X-Api-Key. |
| Bearer token | A fixed token, as Authorization: Bearer <token>. |
| OAuth 2.0 (client credentials) | A short-lived token from the receiving system’s identity provider, as Authorization: Bearer <token>. |
The Authentication setting belongs to the endpoint, not to one automation, so it applies to every automation that sends to that endpoint.
If you switch Authentication to another option and save, the credentials of the previous option are deleted, including an OAuth 2.0 client secret. To switch back, enter those credentials again.
Details to collect before setting up OAuth 2.0
Get these details from whoever runs the receiving system, or from its developer documentation:
- The token URL.
- A client ID and client secret registered for Installer.com.
- The scope, if their identity provider requires one.
- The audience, if their identity provider requires one.
- Whether the client credentials go in the
Authorizationheader or in the request body.
Set up OAuth 2.0 on a webhook endpoint
Saving endpoint settings needs permission to change your organization’s settings.
- Open the automation. Under What happens, select the endpoint tag in Send payload to. The endpoint settings open with the endpoint address as the title.
- Under Authentication, select OAuth 2.0 (client credentials).
- Enter the Token URL.
- Enter the Client ID and the Client secret.
- Enter a Scope if the identity provider requires one.
- Under Where to send the credentials, select Authorization header (Basic) or Request body.
- Enter an Audience if the identity provider requires one.
- Select Save.
The next delivery to the endpoint, including one waiting for a retry, requests a token with the new settings.
OAuth 2.0 fields on a webhook endpoint
| Field | What to enter |
|---|---|
| Token URL | The address where the client ID and secret are exchanged for a token. It must be a public https address with no query string and no # fragment. |
| Client ID | The client’s public identifier. The client ID stays visible after saving. |
| Client secret | The client’s secret. Hidden after saving. To keep the stored secret while you change other fields, leave Client secret blank. To replace it, enter the new one. |
| Scope | The scope the identity provider grants to this client, such as orders.write. Amazon Cognito requires a scope. Leave empty if the identity provider does not use one. |
| Where to send the credentials | Authorization header (Basic) sends the client ID and secret in an Authorization: Basic header. Request body sends them as client_id and client_secret in the request body. Identity providers accept different ones, so use the one the receiving system documents. |
| Audience | The identifier of the receiving application programming interface (API), for identity providers that ask for one, such as Auth0. Amazon Cognito ignores it. Leave empty unless the receiving system documents it. |
How the OAuth 2.0 token exchange works
When Installer.com needs a new token, it sends a token request to the Token URL. With Authorization header (Basic), the request looks like this:
POST /oauth/token
Content-Type: application/x-www-form-urlencoded
Accept: application/json
Authorization: Basic <client_id:client_secret, base64-encoded>
grant_type=client_credentials&scope=orders.write
With Request body, the request has no Authorization header, and the body carries the credentials:
grant_type=client_credentials&scope=orders.write&client_id=<client_id>&client_secret=<client_secret>
The token request includes scope and audience only when Scope and Audience have a value.
The identity provider answers with a 2xx status and JSON that holds the token:
{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"token_type": "Bearer",
"expires_in": 3600
}
The webhook request then goes to the receiving system with Authorization: Bearer eyJhbGciOiJSUzI1NiIs....
How long an OAuth 2.0 token is reused
Installer.com reuses an OAuth 2.0 token for later deliveries to the same endpoint. A burst of deliveries makes one token request, not one per delivery.
- A token is reused until shortly before
expires_inruns out, and never for more than one hour. - A token response with no usable
expires_ingives a token that is reused for about 30 seconds. - Saving a change to any OAuth 2.0 field gets a new token on the next delivery.
When the receiving system answers a webhook with 401 Unauthorized, Installer.com drops the stored token, and the next delivery requests a new one. The delivery that got the 401 fails, because a 401 is a rejected request.
If the receiving system can revoke tokens before they expire, turn on Retry rejected requests under What happens in the automation. The retry then gets a new token.
OAuth 2.0 and the signing secret
A webhook endpoint can use OAuth 2.0 and a signing secret together. OAuth 2.0 and the signing secret answer different questions.
| OAuth 2.0 | Signing secret | |
|---|---|---|
| Proves | Installer.com is allowed to call the receiving system. | The request came from Installer.com and was not changed. |
| Checked by | The receiving system’s API, against its identity provider. | The receiving system’s code, using the webhook-signature header. |
| Set in the endpoint settings under | Authentication | Signing secret |
When the OAuth 2.0 token request fails
A failed token request stops the webhook delivery before anything is sent to the receiving system. Two places show a failed token request:
- In the run, the attempt is marked Token request and shows the error.
- In the endpoint settings, Last token error: below the OAuth 2.0 fields shows what went wrong:
- For an HTTP error, the status, followed by the OAuth 2.0 error code and description when the identity provider sends them.
- For a connection failure, the reason, such as
blocked: ....
Last token error: clears when you save the endpoint settings or when the next token request succeeds.
| Error contains | Likely cause | What to do |
|---|---|---|
invalid_client |
The client ID or secret is wrong, or the identity provider expects the credentials in the other place. | Enter the client secret again. If the error stays, switch Where to send the credentials to the other option. |
invalid_scope |
The scope is missing, misspelled, or not granted to this client. | Correct Scope to what the identity provider grants. |
unauthorized_client |
The client is not allowed to use the client credentials grant. | Ask whoever runs the receiving system to allow the grant for this client. |
The token endpoint did not return JSON |
The Token URL points at a login page or some other page. | Use the token endpoint address from the receiving system’s documentation. |
The token response carried no access_token |
The Token URL answers, but not with a token. | Check the Token URL against the receiving system’s documentation. |
The token endpoint could not be reached (blocked), or blocked: in Last token error: |
The Token URL points at a private network address. Installer.com sends only to public addresses. | Use the identity provider’s public token URL. |
The token endpoint could not be reached with another reason |
The identity provider is down or cannot be reached. | Wait. The delivery is retried. |
A 408, 429 or 5xx answer from the token endpoint, or a connection failure, is retried like any webhook delivery. Any other 4xx answer fails at once, because the same credentials get the same answer. Fix the settings, then select Retry on the failed run.
Related articles
Need help? Contact Installer.com support.
Was this helpful?