How to use JSON connectors to pull data via 2 API calls with an Access Token

In order to make API calls to the endpoints, you must first obtain an access token using your
client_id and client_secret. These credentials are given when you create an API client inside the
shellyak application.
Once the access token has been obtained, it is used on subsequent calls to the API to verify your
access.

Authentication
Get Access Token
Request:

$ curl \
-H "Content-type: application/json" \
-d '{"grant_type": "client_credentials", "client_id": "XXXXXXXXXXXX",
"client_secret": "XXXXXXXXXXXX"}' \
https://auth.shellyak.com/oauth/token

Response:

{
"access_token": "{{ACCESS_TOKEN_VALUE}}",
"refresh_token": "{{REFRESH_TOKEN_VALUE}}",
"expires_in": 3600,
"token_type": "Bearer"
}


API Calls
Get All Locations
Request:

$ curl \
-H "Content-type: application/json" \
-H "Authorization: Bearer {{ACCESS_TOKEN_VALUE}}" \
https://app.shellyak.com/api/location

This is a two-step way to pull data. Any thoughts? Thanks!
I think I should use JSON No Code Connector twice. First, save the token, then use that to pull the actual data.

Best Answer

  • ggenovese
    ggenovese Contributor
    Answer ✓

    The JSON No Code OAuth connector can do this, when you create the connector account you should choose the Client Credentials flow, and Pass Client ID and Secret in Basic Authentication Header options. In the Access Token URL textbox paste in the URL that you use to get the access token.

Answers

  • JerryZ
    JerryZ Member
    edited August 29

    I figured it out.

    But I wonder if a JSON connector can programmatically grab an access token from a dataset and pass it into the header.
    I will fiddle with the JSON No Code OAuth Connector because it might be useful.

  • ggenovese
    ggenovese Contributor
    Answer ✓

    The JSON No Code OAuth connector can do this, when you create the connector account you should choose the Client Credentials flow, and Pass Client ID and Secret in Basic Authentication Header options. In the Access Token URL textbox paste in the URL that you use to get the access token.