Connect to an OAuth2 provider
Create an OAuth provider and an OAuth2 outbound token so server scripts can call another system without holding its credentials.
Connect to an OAuth2 provider when a server script or integration must call a system that uses OAuth2. You end with an outbound token that scripts use by name, and Servicely keeps its access token current.
Before you begin
- You need the
administratorrole. - Register Servicely as a client with the provider. For the Authorization Code grant, register the redirect URL
https://<your-instance>/sso/oauth_callback/. - Have the client ID, client secret, authorization URL, token URL and scopes from the provider.
- For the Authorization Code grant, have the account that will authorise the token ready to sign in.
Steps
-
Go to Administration → Integration → System OAuth providers and select New.
-
Enter a Name, the Client ID and the Client Secret.
-
Set Grant type to Authorization Code or Client Credentials. Use Authorization Code when a user must sign in, and Client Credentials for app-only access.
-
Enter the Token URL and the default Scopes. For Authorization Code, also enter the Authorization URL and the Redirect URL. Save the provider.
-
Go to Administration → Integration → System API outbound tokens and select New.
-
Enter a Name and set Type to OAuth2. Scripts will refer to the token by this name.
-
Select the OAuth Provider you created. Enter Scopes only if this token needs different scopes from the provider. Save the token.
-
For Authorization Code, select Get authorization token. Sign in at the provider’s page and grant consent. The provider returns you to the token form.
-
Check that State is Ready. If it shows Error, read Last message, correct the provider or token, and repeat the previous step.
Variations
Other token types
For a token that does not use OAuth2, create only the outbound token. Set Type, then fill in the fields the form shows:
| Type | Fields to fill in |
|---|---|
| Basic | User name and Password |
| Bearer | Access Key / Token |
| HMAC Body (Servicely) | Access Key / Token and Secret Key, from a System API token on the target Servicely instance |
| Access Key | Access Key / Token and Secret Key |
Client Credentials
With the Client Credentials grant, nobody signs in. Skip the Get authorization token step. Servicely requests an access token from the client ID and secret when the token is first used, and again when it expires.
Result
The token is active and ready. A server script passes the token name to apiTokenAuth on an outbound HTTP request, and Servicely applies the credentials before sending it. Authorization Code tokens are refreshed shortly before they expire. If a refresh fails, State changes to Error and Last message holds the reason.