Access Tokens
Get and use access tokens to make API calls

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:
  • CLIENT_ID: the clientId from the previous step
  • CLIENT_SECRET: the clientSecret from the previous step
  • AUTH_SERVER: The URI for the auth server (see table below)
App URL
Auth Server
API Endpoint
staging.firstresonance.io
or
sandbox.firstresonance.io
staging-auth.buildwithion.com
staging-api.buildwithion.com
app.firstresonance.io
auth.buildwithion.com
api.buildwithion.com
staging.ion-gov.com
or
sandbox.ion-gov.com
staging-auth.ion-gov.com
staging-api.ion-gov.com
app.ion-gov.com
auth.ion-gov.com
api.ion-gov.com
1
$ curl -X POST \
2
--data-urlencode "grant_type=client_credentials" \
3
-d "client_id=CLIENT_ID" \
4
-d "client_secret=CLIENT_SECRET" \
5
https://<AUTH_SERVER>/auth/realms/api-keys/protocol/openid-connect/token
Copied!

Step 3 - Use the API

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:
  • ACCESS_TOKEN: the access token from the previous step
  • API_ENDPOINT: The API endpoint for each environment are listed in the table above.
1
import requests
2
from urllib.parse import urljoin
3
4
access_token = <ACCESS_TOKEN>
5
api_endpoint = <API_ENDPOINT>
6
7
8
headers = {
9
'Authorization': f'{access_token}',
10
'Content-Type': 'application/json'
11
}
12
13
GET_RUNS = '''
14
{
15
runs(first: 10) {
16
edges {
17
node { id title
18
steps {
19
id
20
title
21
}
22
}
23
}
24
}
25
}
26
'''
27
28
query = {
29
'query': GET_RUNS
30
}
31
32
res = requests.post(urljoin(api_endpoint, 'graphql'), headers=headers, json=query)
33
print(res.json())
Copied!
Last modified 1mo ago