In this article:
Overview
Customers have the ability to set up their own API keys to access some features in the Chain.io portal. Below is a guide on how to get your API Key and how it can be used.
Getting Your API Key
To get your API key, you need to navigate to your Workspace Settings, this can be found by clicking the menu button highlighted below, then clicking Workspace Settings.
Once in Workspace Settings, click on Portal API Keys in the Developers section
Next, click the Generate New API Key button to generate a new API key.
A modal window will appear, where you enter the name of the API Key and the user role you wish to assign to the key.
When complete, click Create to generate your API key.
Your key should immediately show up in the table above the button. Clicking the icons next to your API key will display your key and copy your key to the clipboard.
Give the API Key Permission To Another Workspace
By default an api key only grants permission to the workspace where it was created. If it is desired that the key have access to more than one workspace, it can be added as a user:
To grant this API key access to a company, create a new user under any company in the portal with the email address in the format of [Client ID]@api.chain.io. So if the Client ID is ABC1234 then set the email address to ABC1234@api.chain.io
Once you add the API key to a Company, all other interactions with our GraphQL API work just like a normal user.
Using The API Key
When the customer wants to use the API key, they need to exchange it for an Access Token. They do this by sending a POST to https://chainio.auth0.com/oauth/token [https://chainio.auth0.com/oauth/token] with a JSON body like:
{
"client_id": "[CLIENTID GOES HERE]",
"client_secret": "[CLIENT SECRET GOES HERE]",
"audience": "https://portal-api.chain.io",
"grant_type": "client_credentials"
}
The response with look like
{
"access_token": "abc123",
"expires_in": 86400,
"token_type": "Bearer"
}
The application can then submit the access token with Bearer authentication like Bearer abc123 to our graphql endpoint at https://portal-api.chain.io/graphql
Customers can also explore the GraphQL api with our gui at https://portal.chain.io/graphql
See more information at: https://support.chain.io/hc/en-us/articles/360053497734-Using-the-Chain-io-Portal-GraphQL-API
Comments
0 comments
Article is closed for comments.