Setting up an OAuth 2.0 Authentication

How to set up a sample OAuth flow using Facebook as an example

Create an Authentication

From the Configuration menu, select Authentication Settings and click Create New Authentication.

Select the authentication type from the menu and complete the data for the authentication type.

For OAuth 2.0, you will need to provide a the Client ID and Client Secret. These are obtained from the API provider usually by registering an app with the provider's developer program. You will also need to an Authorize URL and a Get Token URL. These are found in the provider's API documentation.

Furthermore, you the API provider may require you to enter a callback URL. This is given the page and will have a form similar to https://client.apimetrics.io/tokens/callback.

Create a Token

To create the token, click on the Create Token button. This takes you to a dialog. Enter a suitable name for the token. From the Grant Type dropdown, choose Authorization Code or Client Credentials as directed in the API documentation. Authorization Code is most common. Enter any necessary scopes as directed in the API documentation.

When you click the Authenticate with... (where ... is replaced by the name of the authentication), you will redirected to the external site to authorize the token creation. In the case of Facebook, this will require you to login into Facebook with an account that is associated with the Client ID and Client Secret you used.

If you are familiar with OAuth, it is also possible to create the token by entering the appropriate values manually. 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 an API call to an authentication endpoint to obtain the values for the token, which would be extracted from the returned JSON payload.

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.