Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Generate token using cookie in responseText (ConnectionJSON REST)

abm15
New Contributor III
New Contributor III

Hi,

I am facing an issue mapping the authentication token in the ConnectionJSON for REST connector.

The token is generated from a basic logon API using username and password.

Below is the Postman response to the logon request. The token is shared in the body of the response in plain text:

abm15_0-1707258968618.png

Below is the Saviynt logs showing the token in the "responseText" field:

abm15_1-1707259112976.png

I need to map the value in "responseText" to my token in the ConnectionJSON.

Then I need to pass the token in the httpHeaders for other JSONs (ex: CreateAccount, UpdateAccount, etc.)

How can I achieve this mapping in the ConnectionJSON?

Below is my current ConnectionJSON and CreateAccountJSON.

ConnectionJSON:

{
"authentications": {
"userAuth": {
"authType": "Basic",

"url": "xxxxx",

"httpMethod": "POST",
"httpParams": {},
"httpHeaders": {},
"httpContentType": "text/html",
"properties": {
"userName":"xxxxx",
"password":"xxxxx"
},

"expiryError": "ExpiredAuthenticationToken",
   "authError": [
"InvalidAuthenticationToken",
"Couldn’t aunthenticate you",
"AuthenticationFailed"
],

"timeOutError": "Read timed out",
"errorPath": "error.code",
"maxRefreshTryCount": 5,

"tokenResponsePath": "responseText",
}
}
}

CreateAccountJSON:

{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "xxxxxxx",
"httpMethod": "POST",
"httpParams": "{xxxxx}",
"httpHeaders": {
"Cookie": "${responseText}"
},
"httpContentType": "application/json",
"successResponses": {
"Status": "SUCCESS"
}
}
]
}

10 REPLIES 10

rushikeshvartak
All-Star
All-Star

Can you share postman screenshot for create account api to see body parameters 

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


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Hi Rushikesh,

Body for create user request in Postman is below. Blanked out is simply the attribute map in JSON format.

abm15_0-1707315304768.png

And the curl command is below.

abm15_1-1707315481020.png

I need to get the responseText from connectionJSON to map to the "Cookie" used in the header for this request.

Thanks.

Hi Rushikesh,

I have shared the information you requested. Do you have any suggestions for resolving this issue?

Thanks.

Establish connection in create account json and try instead of connection json


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Thanks Rushikesh,

Do you have any sample JSON or format on how to establish connection in the CreateAccountJSON directly?

Spoiler
{
"accountIdPath": "call1.message.id",
"dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX",
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "https:/<domain name>/2.0/users",
"httpMethod": "POST",
"httpParams": "{\"login\":\"${user.username}\",\"name\": \"${user.firstname}\"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
201
]
}
},
{
"name": "call2",
"connection": "userAuth",
"url": "https:/<domain name>/2.0/folders",
"httpMethod": "POST",
"httpParams": "{\"name\":\"${response.call1.message.name}_${response.call1.message.id}\",\"parent\":{\"id\":\"0\"}}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
201
]
}
}
]
}

Refer https://docs.saviyntcloud.com/bundle/Dev-Handbook-REST-v24x/page/Content/Developers-Handbook.htm


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

AG
Regular Contributor II
Regular Contributor II

Is there a way to mask credentials when using connection parameters in CRUD jsons?

Got , it . We can refer it dynamically from connection.

AG
Regular Contributor II
Regular Contributor II

Is this a valid token response? Since it returns in plaintext and not in json format?

abm15
New Contributor III
New Contributor III

This is what I need an answer to. And if the response is valid, how do I map the token response in Saviynt, so that I can pass the token in other JSONs?

abm15
New Contributor III
New Contributor III

We have a solution which involves establishing the connection directly in the Create, Update, and Remove Account JSONs (connection properties masked), then mapping the token response from the connection to the subsequent Create/Update/Delete API request call.

Please find examples below. Also note, this is NOT working the same for the ImportAccountEntJSON. This solution is working in the Create, Update, and Remove Account JSONs.

Sample Create Account JSON:

{

"accountIdPath": "accountName",

"responseColsToPropsMap": {},

"call": [

{

"name": "call1",

"connection": "acctAuth",

"url": "<url>",

"httpMethod": "POST",

"httpHeaders": {

"Content-Type": "application/x-www-form-urlencoded"

},

"httpParams": "{\"userid\":\"${connection.properties.userName}\",\"password\":\"${connection.properties.password}\"}",

"httpContentType": "application/x-www-form-urlencoded",

"successResponses": {

"statusCode": [

200,

201

]

}

},

{

"name": "call2",

"connection": "acctAuth",

"url": "<url>",

"httpMethod": "POST",

"httpParams": "{\"createUser\":{\"<attr1>\":\"${<attr1mapping}\"}}",

"httpHeaders": {

"Cookie": "${response.call1.message.responseMessage}"

},

"httpContentType": "application/json",

"successResponses": {

"userStatus": "PROVISIONED"

}

}

]

}