Skip to main content

Setting up an OAuth 2.0 Authentication

Create an Authentication​

In the sidebar, under Configure Monitoring, select Monitor Authentication (open it), then select Add new Auth Setting.

In the Create Authentication panel, set Authentication Type to OAuth 2 and complete its fields.

For OAuth 2.0, you need the Client ID and Client Secret. You usually get these from the API provider by registering an app with the provider's developer program. You also need an Authorize URL and a Get Token URL, which are in the provider's API documentation.

Create Authentication panel set to OAuth 2, with the Authorize URL, Get Token URL, Advanced options, and Client ID and Client Secret fields

Select Save. The auth setting's page then shows its Callback URL, https://client.apimetrics.io/tokens/callback/. Register this callback URL with the API provider to use the token wizard.

Saved OAuth 2 auth setting showing its Authorize URL, Get Token URL, the Callback URL to register with the provider, and its Client ID

Create a Token​

To create the token, open the auth setting and select Add New Token. In the Add New Token panel, enter a name for the token. Under Get token from provider, choose Authorization Code or Client Credentials from the Grant Type list, as the API documentation directs. For user-authenticated calls, Authorization Code is the usual choice. Enter any scopes the API documentation requires in Scope.

Add New Token panel for an OAuth 2 auth setting with the Grant Type list open showing Authorization Code and Client Credentials, the Callback URL, and the Authenticate with Example OAuth 2 button

When you select Authenticate with ... (where ... is the name of the auth setting), you are sent to the provider's site to authorize the token. Sign in with an account that is associated with the Client ID and Client Secret you used.

If you are familiar with OAuth, you can also select Enter token values manually and create the token from the appropriate values. This is generally not recommended, although might be necessary in certain circumstances as often found that the automated token generation process fails for some reason. In this situation, it would normally be necessary to use a monitor to an authentication endpoint to obtain the values for the token, which would be extracted from the returned JSON payload.

Auth setting detail page with its tokens table listing a saved token, with Expires, Expires In, and Last Updated columns

After the token generation has been authenticated by the API provider, you will be returned to APImetrics and will see the new token in your list of tokens for that API provider.

Use the Auth Settings in a call​

When you setup or edit a call nex that uses the authentication, you can then choose the authentication and then the associated token from the dropdowns in the call editor.

Monitor editor with the Authentication section highlighted, showing the Settings and Token dropdowns with an auth setting and token selected