Forum Discussion

API_User's avatar
API_User
Equinix Employee
2 years ago

Fabric API generate token using client_credentials

I am trying to generate token using this method but in Postman:

Access Token using grant_type = client_credentials (Recommended).

POST 'https://api.equinix.com/oauth2/v1/token' -H "content-type: application/json" -d '{ "grant_type": "client_credentials", "client_id": "******", "client_secret": "****" }'

I have the body set as specified in the link: https://developer.equinix.com/docs?page=/dev-docs/fabric/overview but when I execute the query I get this error:

{
    "errorDomain": "apps-fqa",
    "errorTitle": "Unable to Process the Request",
    "errorCode": "S1002",
    "developerMessage": "Failed to execute the ExtractVariables: extractjsonparams",
    "errorMessage": "Unable to Process the Request, Please try again later."
}

I have a client_id and client_sercret generated and have tested it with Terraform. What am I missing?

Thanks!

  • Got it, used wrong credentials

     

    access_token=`curl -s --request POST \ 
    --url https://${endpoint_url}/oauth2/v1/token \
    --header 'accept: application/json' \
    --header 'content-type: application/json' \
    --data '{"client_id":"'${client_id}'","client_secret":"'${client_secret}'","grant_type":"client_credentials"}' \
    | jq -r '.access_token'`

     

  • API_User's avatar
    API_User
    Equinix Employee

    Got it, used wrong credentials

     

    access_token=`curl -s --request POST \ 
    --url https://${endpoint_url}/oauth2/v1/token \
    --header 'accept: application/json' \
    --header 'content-type: application/json' \
    --data '{"client_id":"'${client_id}'","client_secret":"'${client_secret}'","grant_type":"client_credentials"}' \
    | jq -r '.access_token'`

     

  • API_User's avatar
    API_User
    Equinix Employee
    Nice, glad you got this one. Should have replied when I was able to get it working in Postman, few hours later posting this message 🙂 .
    Used raw rather than json as it is normally in a cli.