API authentication with cURL

Requirements

You must have a valid API token and Client ID; see Get an API Token and Client ID.

Authenticate using cURL

  1. Open your terminal.

  2. Identify your target /auth endpoint URL based on your organization's cloud platform and region. For information about identifying your platform host, see Region, warehouse, and feature support.

    https://api.sigmacomputing.com/v2/auth/token
    
    https://aws-api.sigmacomputing.com/v2/auth/token
    
    https://api.ca.aws.sigmacomputing.com/v2/auth/token
    
    https://api.eu.aws.sigmacomputing.com/v2/auth/token
    
    https://api.au.aws.sigmacomputing.com/v2/auth/token
    
    https://api.us.azure.sigmacomputing.com/v2/auth/token
    
  3. Run the following command:

    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}'
    
  4. Expected Response:

    {  
     "access_token": {access_token},  
     "refresh_token": {refresh_token},  
     "token_type": "bearer",  
     "expires_in": 3600  
    }
    

    📘

    Use the access_token from the response in subsequent API calls as a Bearer token.

    Try it with the WhoAmI endpoint to verify it is valid.

    Note that the access token expires after 1 hour (3600 seconds).

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}'