Access Tokens | ION Factory OS

The manual for the New ION Experience

Check it out! Documentation

For the complete documentation index, see llms.txt. This page is also available as Markdown.

Step 1 - Generate an API key

Follow the steps here to create an API key.

The API key will include a clientId and clientSecret.

Step 2 - Get an access token

Make the API call shown below and update the following variables:

App URI Auth Server API Endpoint
staging.firstresonance.io staging-auth.buildwithion.com https://staging-api.buildwithion.com
app.firstresonance.io auth.buildwithion.com https://api.buildwithion.com
staging.ion-gov.com auth-staging-gov.buildwithion.com https://api-staging-gov.buildwithion.com
app.ion-gov.com auth-production-gov.buildwithion.com https://api-production-gov.buildwithion.com
staging.ion-aus.com auth-staging-aus.buildwithion.com https://api-staging-aus.buildwithion.com
app.ion-aus.com auth-production-aus.buildwithion.com https://api-production-aus.buildwithion.com
$  curl -X POST \
        --data-urlencode "grant_type=client_credentials" \
        -d "client_id=CLIENT_ID" \
        -d "client_secret=CLIENT_SECRET" \
    https://<AUTH_SERVER>/realms/api-keys/protocol/openid-connect/token

Here is a script to get your access token via python. We also have our public repository linked below for some sample scripts.

We have a public repository published for some API queries via python scripts.

The below also shows a very basic python script to query runs from ION.

To use, replace the following:

import requests
from urllib.parse import urljoin

access_token = <ACCESS_TOKEN>
api_endpoint = <API_ENDPOINT>

headers = {
    'Authorization': f'{access_token}',
    'Content-Type': 'application/json'
}

GET_RUNS = '''
{
    runs(first: 10) {
        edges {
            node { id title
                steps {
                    id
                    title
                }
            }
        }
    }
}
'''

query = {
    'query': GET_RUNS
}

res = requests.post(urljoin(api_endpoint, 'graphql'), headers=headers, json=query)
print(res.json())

If you are using a tool like Postman or Insomnia, be sure to add a /graphql to your endpoint. Example: https://staging-api.buildwithion.com/graphql