Board API query: How to authenticate and use Secrect Key

Options

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

  • Mike Spagnolo
    Options

    This Is what I get when pasting into CMD. {"message":"Authorization has been denied for this request."}

  • Leone Scaburri
    Leone Scaburri Employee
    First Anniversary First Comment Level 100: Foundations of Building in Board Level 200: Leveraging Board for Business Insights
    edited July 2023
    Options

    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

  • Mike Spagnolo
    Options

    Are you able to provide a full example of the process and API call? I assume its something like this.

    1. 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)

  • Andrea Duò
    Options

    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 https://www.boardmanual.com/2021/summer/administration/Subscription_Hub/1_Users/Client_API.htm

    Andrea

  • Mike Spagnolo
    Options

    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.

  • Andrea Duò
    Options

    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

  • Nicolas BENDONGUE
    Options

    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

  • Samson Sunny
    Samson Sunny Employee
    April Badge of the Month Community Captain February Badge of the Month 5 Likes
    edited November 2023
    Options

    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.

  • Andrea Duò
    Options

    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

    https://www.boardmanual.com/2023/summer/release-notes/board-2022-spring-release-release-notes/release-notes/main-features/rest-apis.htm

    Andrea