API Authentication with cURL
Summary of Content
Requirements
Authenticate using cURL
Generate a refresh token
Related Resources
Requirements
You must have a valid API token and Client ID; see Get an API Token and Client ID.
Authenticate using cURL
- Open your terminal.
- Identify your target /auth endpoint
For GCP organizations, use:POST https://api.sigmacomputing.com/v2/auth/token
For AWS organizations, use:
POST https://aws-api.sigmacomputing.com/v2/auth/token
- Run the following command:
An access token lasts for 1 hour.
curl --location --request POST '{endpoint-url}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id={client_id}' \
--data-urlencode 'client_secret={api_token}' -
Expected Response:
{
"access_token": {access_token},
"refresh_token": {refresh_token},
"token_type": "bearer",
"expires_in": 3600
}Use the
access_token
from the response in future API calls. Try it with the WhoAmI endpoint.
Generate a refresh token
Use the refresh_token
to refresh an expired auth token.
Run the following command:
curl --location --request POST '{endpoint-url}' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=refresh_token' \ --data-urlencode 'refresh_token={refresh_token}' \ --data-urlencode 'client_id={client_id}' \ --data-urlencode 'client_secret={api_token}'
Related Resources
Get an API Token and Client ID