Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

access_token is not picking dynamically in REST connection

UtkarshSingh
New Contributor
New Contributor

Hi,

I am working on REST integration where access_token is not picking dynamically in other jsons like create and addaccess json.

PFA connection json i am pasting below used dummby valued wherevered required

{"authentications":{"acctAuth":{"authType":"oauth2","httpHeaders":{"Content_Type":"application/x-www-form-urlencoded"},"authError":["Unable to authenticate the client","Invalid OAuth token Bearer"],"url":"https://abcd.auth.marketingcloudapis.com/v2/Token","httpMethod":"POST","httpContentType":"application/x-www-form-urlencoded","errorPath":"","maxRefreshTryCount":5,"tokenResponsePath":"access_token","tokenType":"Bearer","authHeaderName":"Authorization","accessToken":"abcd","httpParams":{"grant_type":"client_credentials","client_secret":"abcd","client_id":"abcd"},"retryFailureStatusCode":[401,403,500]}}}

9 REPLIES 9

naveenss
All-Star
All-Star

Hi @UtkarshSingh what is the error you're seeing? Also, can you share the sample API response from postman for the access token endpoint?

 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

UtkarshSingh
New Contributor
New Contributor

{"auditDetails":{"Role":[{"headers":null,"message":"","statusCode":null,"description":null,"status":"Failed"}]},"Role":{"headers":null,"message":"","statusCode":null,"description":null,"status":"Failed"}}

Please share postman screenshot and curl command [Refer https://codingnconcepts.com/postman/how-to-generate-curl-command-from-postman/ ]



⚠️‼️‼️Do not upload any attachments that contain sensitive information, such as IP Addresses, URLs, Company/Employee Names, Email Addresses, etc.‼️‼️⚠️

 

{
  "authentications": {
    "acctAuth": {
      "authType": "oauth2",
      "httpHeaders": {
        "Content_Type": "application/x-www-form-urlencoded"
      },
      "authError": [
        "Unable to authenticate the client",
        "Invalid OAuth token Bearer"
      ],
      "url": "https://abcd.auth.marketingcloudapis.com/v2/Token",
      "httpMethod": "POST",
      "httpContentType": "application/x-www-form-urlencoded",
      "errorPath": "",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "access_token",
      "tokenType": "Bearer",
      "authHeaderName": "Authorization",
      "accessToken": "abcd",
      "httpParams": {
        "grant_type": "client_credentials",
        "client_secret": "abcd",
        "client_id": "abcd"
      },
      "retryFailureStatusCode": [ null,
        401,
        403,
        500
      ]
    }
  }
}

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

UtkarshSingh
New Contributor
New Contributor

curl --location 'https://abcd.marketingcloudapis.com/v2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=abcd' \
--data-urlencode 'client_secret=abcd' \
--data-urlencode 'grant_type=client_credentials'APIERROR.PNG

Hi @UtkarshSingh try with the below JSON. Please add a GET call in the testConnectionParams to and validate in the logs when you hit "Save and Test Connection". Let me know the result.

{
  "authentications": {
    "acctAuth": {
      "authType": "oauth2",
      "url": "https://abcd.marketingcloudapis.com/v2/token'",
      "httpMethod": "POST",
      "httpParams": {
        "grant_type": "client_credentials",
        "client_id": "abcd",
        "client_secret": "abcd"
      },
      "httpContentType": "application/x-www-form-urlencoded",
      "httpHeaders": {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      "retryFailureStatusCode": [
        401,
        403
      ],
      "expiryError": "ExpiredAuthenticationToken",
      "authError": [
        "SESSION_NOT_VALID",
        "AuthenticationFailed",
        "ExpiredJwtException",
        "401 Unauthorized"
      ],
      "timeOutError": "Read timed out",
      "errorPath": "code",
      "maxRefreshTryCount": 6,
      "tokenResponsePath": "access_token",
      "tokenType": "Bearer",
      "accessToken": "abcd",
      "testConnectionParams": {
        "http": {
          "url": "https://xxxxxxxx",
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/json",
          "httpMethod": "GET"
        },
        "successResponse": [],
        "successResponsePath": "",
        "errors": [
          "Couldn't authenticate you"
        ],
        "errorPath": "error"
      }
    }
  }
}

 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

{
"authentications": {
"acctAuth": {
"authType": "oauth2",
"httpHeaders": {
"Content-Type": "application/x-www-form-urlencoded"
},
"authError": [
"Unable to authenticate the client",
"Invalid OAuth token Bearer"
],
"url": "https://abcd.auth.marketingcloudapis.com/v2/Token",
"httpMethod": "POST",
"httpContentType": "application/x-www-form-urlencoded",
"errorPath": "",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "",
"authHeaderName": "Authorization",
"accessToken": "Bearer abcd",
"httpParams": {
"grant_type": "client_credentials",
"client_secret": "abcd",
"client_id": "abcd"
},
"retryFailureStatusCode": [ null,
401,
403,
500
]
}
}
}


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

it worked after removing bearer from token type 

Updated response

Please click the 'Accept As Solution' button on the reply (or replies) that best answered your original question and hit 'Kudos' button 👍.


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

UtkarshSingh
New Contributor
New Contributor

Hi Rushi same error status code null