Skip to main content

Using the OAuth2 Client Credentials grant with the HTTP module

The Client Credentials grant type enables Make to obtain an access token with the help of Client ID and Client Secret. Make doesn't support the Client Credentials Grant flow of creating an OAuth 2.0 connection in the HTTP - Make an OAuth 2.0 request module. However you can use the HTTP - Make a request module to get an access token and then make an API call.

Important

You need to know your Client ID and Client Secret to get an access token. Read about getting credentials.

Get an access token

First, you need to make a request for getting an access token from the service.

  1. In your scenario, add the HTTP - Make a request module.

  2. In URL, enter the request URL for getting the access token.

    Tip

    Refer to the app API documentation to get the request URL.

  3. In Method, select the appropriate method for the endpoint

  4. Optional: In Headers, specify a request header.

  5. Optional: In Query String, enter needed parameters.

  6. In Body type, select one of the following:

    • The Raw option. Proceed to the step 7.

    • The Application/x-www-form-urlencoded option. Proceed to the step 9.

  7. In Content type, select JSON (application/json).

  8. In Request content, enter the request that should contain the following:

    • The grant type: client_credentials.

    • Your Client ID.

    • Your Client Secret.

    • Optional: scopes required by the service.

    Tip

    The request example:

    {

    "grant_type": "client_credentials",

    "client_id": 4342c38243cb2o84732c234c

    "client_secret": 34sdf7843fno8s7dg

    }

  9. In case you chose the Application/x-www-form-urlencoded body type: In Fields, add the grant type, the Client ID, and the Client Secret.

    HTTP_best_second.png
  10. Run the module.

In the modules output, you get an access token and a token type:

IMG_20240122_212657_350.jpg

Authorize in the service

After getting the access token, you can make the desired OAuth 2.0 request to the service using the same type of HTTP modules.

  1. In the same scenario, add the second HTTP - Make a request module.

  2. In URL, enter the a request URL for an endpoint you want to reach.

  3. In Method, select the appropriate method for the endpoint.

  4. In Headers, add an item:

    1. Name: Authorization.

      HTTP_second_module.png
    2. Value: enter the token type you got in the output of the previous module, and map the value itself.

      Note

      In this example, the token type is Bearer, but it may vary depending on an app.

      Some apps API require additional headers. Refer to the app API documentation to learn about the token type and headers.

You can make the needed request using the client credentials grant type.