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

Connection JSON GetwithBody Token Call

Bwagne
New Contributor III
New Contributor III

I'm trying to setup a connection and the parameters must be sent in the body. I've tried several other options in Postman and only sending in Body works.

I believe this is just a syntax issue, but there's no documentation on how to build these.
This body in Postman seems to work:

Bwagne_0-1726059737637.png

This is what the curl command looks like:
curl --location --request GET "https://server.website.com/api/v1/token" --header "Content-Type: application/json" --data-raw "grant_type=password&username=USERNAME&password=PASSWORD"


I've tried this and it doesn't seem to work:
{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://server.website.com/api/v1/token",
"httpMethod": "GETWITHBODY",
"httpParams": "{\"grant_type\"=\"password\"&\"username\"=\"USERNAME\"&\"password\"=\"PASSWORD\"}",
"httpHeaders": {
"Content-Type": "text/plain"
},
"httpContentType": "application/json",
"authError": [
"400"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"authHeaderName": "Authorization",
"accessToken": "Bearer abcd",
"retryFailureStatusCode": [
401
]
}
}
}

21 REPLIES 21

rushikeshvartak
All-Star
All-Star

Use below

{
  "authentications": {
    "userAuth": {
      "authType": "oauth2",
      "url": "https://server.website.com/api/v1/token",
      "httpMethod": "GETWITHBODY",
      "httpParams": {
        "grant_type": "password",
        "username": "USERNAME",
        "password": "PASSWORD"
      },
      "httpHeaders": {
        "Content-Type": "text/plain"
      },
      "httpContentType": "application/json",
      "authError": [
        "400"
      ],
      "errorPath": "errorCode",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "access_token",
      "tokenType": "Bearer",
      "authHeaderName": "Authorization",
      "accessToken": "Bearer abcd",
      "retryFailureStatusCode": [
        401
      ]
    }
  }
}

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

Bwagne
New Contributor III
New Contributor III

This didn't seem to work.  I added a testConnectionParams section just to remove my Import out of the equation.  That didn't work either.

 

{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://server.website.com/api/v1/token",
"httpMethod": "GETWITHBODY",
"httpParams": {
"grant_type": "password",
"username": "USERNAME",
"password": "PASSWORD"
},
"httpHeaders": {
"Content-Type": "text/plain"
},
"httpContentType": "application/json",
"authError": [
"400"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"authHeaderName": "Authorization",
"accessToken": "Bearer abcd",
"retryFailureStatusCode": [
401
],
"testConnectionParams": {
"http": {
"url": "https://server.website.com/api/v1/users",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"httpMethod": "GET"
},
"successResponse": [],
"successResponsePath": "",
"errors": [
"Couldn't authenticate you"
],
"errorPath": "error"
}
}
}
}

{
  "authentications": {
    "userAuth": {
      "authType": "oauth2",
      "url": "https://server.website.com/api/v1/token",
      "httpMethod": "GETWITHBODY",
      "httpParams": {
        "grant_type": "password",
        "username": "USERNAME",
        "password": "PASSWORD"
      },
      "httpHeaders": {
        "Content-Type": "application/json"
      },
      "httpContentType": "application/json",
      "authError": [
        "400"
      ],
      "errorPath": "errorCode",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "access_token",
      "tokenType": "Bearer",
      "authHeaderName": "Authorization",
      "accessToken": "Bearer abcd",
      "retryFailureStatusCode": [
        401
      ],
      "testConnectionParams": {
        "http": {
          "url": "https://server.website.com/api/v1/users",
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/json",
          "httpMethod": "GET"
        },
        "successResponse": [],
        "successResponsePath": "",
        "errors": [
          "Couldn't authenticate you"
        ],
        "errorPath": "error"
      }
    }
  }
}

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

Bwagne
New Contributor III
New Contributor III

That didn't work either

 

Please share logs


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

Bwagne
New Contributor III
New Contributor III

Updated connection with Showlogs, but not much difference in logging.

Can you try once with post in postman 

2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696521634Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestProvisioningService - Got Webservice API Response: [headers:[Cache-Control: private, Content-Type: application/json; charset=utf-8, Server: Microsoft-IIS/10.0, WWW-Authenticate: Bearer, X-Robots-Tag: noindex, Strict-Transport-Security: max-age=8; includeSubDomains, Date: Wed, 11 Sep 2024 17:29:26 GMT, Content-Length: 61], responseText:{message"":""Authorization has been denied for this request.""}", cookies:[]," statusCode:401]""",,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696534534Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestUtilService - pullObjectsByRest - responseStatusCode ::401",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696657535Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] ERROR rest.RestProvisioningService - Exception in pullObjectsByRest :401",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696679935Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] ERROR rest.RestProvisioningService - Inside token Expiry Exception block. connectionParamMap.refreshTryCount : 0",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696693735Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestProvisioningService - Incrementing connectionParamMap.refreshTryCount : 1",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696701835Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestProvisioningService - maxRefreshTryCount : 5",,,,
2024-09-11T17:29:27.888+00:00,ecm,,null-4bk4d,,"2024-09-11T17:29:27.696808835Z stdout F 2024-09-11 17:29:27,696 [http-nio-8080-exec-8] DEBUG rest.RestUtilService - Calling https://server.website.com/api/v1/token",,,,


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

Bwagne
New Contributor III
New Contributor III

POST definitely works in Postman, I was trying to switch to GET as they both work and I only saw getwithbody and nothing for POST. I had already tried a few things with POST.

Share logs with POST


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

Bwagne
New Contributor III
New Contributor III
 

It seems your credentials are wrong or have some special characters


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

The credentials do have special characters.  Do I need to escape them somehow?

stalluri
Valued Contributor
Valued Contributor

@Bwagne 

Try changing the password and test it.


Best Regards,
Sam Talluri
If you find this a helpful response, kindly consider selecting Accept As Solution and clicking on the kudos button.

Can you let us know what all special characters in password ?


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

@ and . are both in there

Can't change the password as it is a service account used for many things.

It should not cause issue.

Does hardcoded token works ?


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

Haven't setup with a hardtoken but found your post on that.

I tried this and it still failed:
{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://server.website.com/api/v1/token",
"httpMethod": "POST",
"httpParams": "",
"httpHeaders": {
"Content-Type": "application/json"
},
"httpContentType": "application/json",
"authError": [
"400"
],
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"authHeaderName": "Authorization",
"accessToken": "Bearer tokenvalue",
"token":"tokenvalue",
"retryFailureStatusCode": [
401
],
"testConnectionParams": {
"http": {
"url": "https://server.website.com/api/v1/users",
"httpHeaders": {
"Authorization": "${token}"
},
"httpContentType": "application/json",
"httpMethod": "GET"
},
"successResponse": [],
"successResponsePath": "",
"errors": [
"Couldn't authenticate you"
],
"errorPath": "error"
}
}
}
}

Bwagne
New Contributor III
New Contributor III

I originally set it to ${connection.token} but that didn't make sense and also didn't work

stalluri
Valued Contributor
Valued Contributor

@Bwagne 

Try using the below values in the import JSON. as you have hardcoded the value.

${token}
${access_token}


Best Regards,
Sam Talluri
If you find this a helpful response, kindly consider selecting Accept As Solution and clicking on the kudos button.

"Authorization": "${access_token}"
 In test connection param


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

stalluri
Valued Contributor
Valued Contributor

@Bwagne  Can you test with below Json.

{
    "authentications": {
        "userAuth": {
            "authType": "oauth2",
            "url": "https://server.website.com/api/v1/token",
            "httpMethod": "GETWITHBODY",
            "httpParams": "{\"grant_type\":\"password\",\"username\":\"USERNAME\",\"password\":\"PASSWORD\"}",
            "httpHeaders": {
                "Content-Type": "application/json"
            },
            "httpContentType": "application/json",
            "authError": [
                "400"
            ],
            "errorPath": "errorCode",
            "maxRefreshTryCount": 5,
            "tokenResponsePath": "access_token",
            "tokenType": "Bearer",
            "authHeaderName": "Authorization",
            "accessToken": "Bearer abcd",
            "retryFailureStatusCode": [
                401
            ]
        }
    }
}

Best Regards,
Sam Talluri
If you find this a helpful response, kindly consider selecting Accept As Solution and clicking on the kudos button.