Board API query: How to authenticate and use Secrect Key
Can anyone show me an example of calling the board api queries? I have am API user setup with a secrect key, and a query.
example. curl -X GET "http://p-p-board4/public/ARGDB/query/indexPricesNymex"
Answers
-
This Is what I get when pasting into CMD. {"message":"Authorization has been denied for this request."}
0 -
Hi @Mike Spagnolo,
if you are using Board public API on a recent version (Spring '22 onward) make sure you properly configured the authorization:
- Grant Type: Client Credentials
- Scope: public-api
- Client Authentication: Send client credentials in body
- Client Id: boardapiclient
- Client secret: *************
- auth URL: https://your-subscription-hub-url/identity/connect/token
- Access token URL: https://your-subscription-hub-url/identity/connect/token
0 -
Are you able to provide a full example of the process and API call? I assume its something like this.
- Authenticate
POST to https://your-subscription-hub-url/connect/authorize
(please show what the body object and headers should be)
2. Get Access Token
POST to URL: https://your-subscription-hub-url/connect/token
(please show what the body object and headers should be)
3. Get the Data from Endpoint
GET to URL: https://your-subscription-hub-url/endpoint/<token>
(please show what the URI should look like for adding the token)
0 -
Hi Mike,
here are the CURL command, hopefully they can help you.
POST Request to get the Access Token
curl --data "grant_type=client_credentials&scope=public-api&client_id=<your_API_client_user>&client_secret=<your_API_client_password>" http://p-p-board4/identity/connect/token
GET Request to get API Query data
curl -H "Authorization: Bearer <access_token>" http://p-p-board4/public/ARGDB/query/indexPricesNymex
As for the API Client user, please refer to this page
Andrea
0 -
I am unable to get the token. When I run
POST curl --data "grant_type=client_credentials&scope=public-api&client_id=<your_API_client_user>&client_secret=<your_API_client_password>" http://p-p-board4/identity/connect/token
I get an error {"error":"unauthorized_client"}. I have setup the api user in board with the name "boardpublicapiclient" and the secret key that was referenced in the documentation.
0 -
Hi Mike,
I suggest you to open a case on our support portal support.board.com so we can take a look at this in detail and keep track of the analysis.
Thanks!
Andrea
0 -
Hi @Andrea Duò
According to a recent discussion with the support team, it looks like the is a mistake on the following
curl --data "grant_type=client_credentials&scope=public-api&client_id=<your_API_client_user>&client_secret=<your_API_client_password>" http://p-p-board4/identity/connect/token
/identity is not needed
thanks
0 -
Hi Nicolas,
You are right the "identity" in the Access Token url is not required since your Board environment is on cloud and has a subscription hub.
Just pointing out the parameters required to obtain the authorization token for two different installations/scenarios here:
When the Board environment is in the cloud and has a subscription hub (idp)
- Grant Type: "Client Credentials"
- Access Token URL: https://your-subscription-hub-url/connect/token
- Client ID: boardpublicapiclient
- Client Secret: ************
- Scope: "public-api"
- Client Authentication: "Send client credentials in body"
When the Board environment is on-premises or is on cloud without a subscription hub (idp)
- Grant Type: "Client Credentials"
- Access Token URL: https://your-platform-url/identity/connect/token
- Client ID: boardpublicapiclient
- Client Secret: ************
- Scope: "public-api"
- Client Authentication: "Send client credentials in body"
Thanks,
Samson.2 -
Thanks @Samson Sunny!
@Nicolas BENDONGUE, the same explanation of the difference between Board on-premise and cloud for the token URL can be found on this page
Andrea
2