Announcing the SAVIYNT KNOWLEDGE EXCHANGE unifying the Saviynt forums, documentation, training, and more in a single search tool across platforms. Click HERE to read the Announcement.

Need help to have the token refreshed automatically for REST connector

pborah
Regular Contributor
Regular Contributor

Hi there,

We are using a REST connector for one of the application and have the basic token authentication. However every time the token is getting regenerated and we need to submit that inside connection in saviynt. Please suggest how can we have the token refreshed by its own. Below is the connection file:

{"authentications":{"userAuth":{"authType":"oauth2","httpHeaders":{"httpContentType":"application/x-www-form-urlencoded"},"authError":["User Not Authenticated","FAILURE","INVALID_SESSION_ID","INVALID_DATA","METHOD_NOT_SUPPORTED"],"url":"https://test.test.com/","httpMethod":"POST","httpContentType":"application/x-www-form-urlencoded","errorPath":"errors.type","maxRefreshTryCount":5,"tokenResponsePath":"sessionId","tokenType":"Basic","authHeaderName":"Authorization","accessToken":"Basic BE6D3D7C3B87C81D234FC53C9C13E1KDKDLK;LL04A3C59E75DD8374BB8868C0E7F4C7515CF274A3ACA54DE032D352B84B8D22C9C5A30DBD","httpParams":{"refresh_token":"${refresh_token}","password":"test#","grant_type":"refresh_token","username":"test"},"retryFailureStatusCode":[401,403,500]}}}

3 REPLIES 3

shivmano
Regular Contributor III
Regular Contributor III

@pborah, looks like there are few things missing in your connection JSON. 

I see you are reading the refresh token dynamically, in your httpsparams> "refresh_token": "${refresh_token}", but there is no refreshTokenResponsePath to read the refresh token on expiry. However, if your refresh token is static, then you can just hardcode your refresh token in the httpparams. Otherwise, you can refer to below sample json to know how we can read the refresh token dynamically by specifying the refreshTokenResponsePath

{
"authentications": {
"userAuth": {
"authType": "oauth2",
"url": "https://<domain name>/v1/access_token",
"httpMethod": "POST",
"httpParams": {
"client_id": "<client ID>",
"client_secret": "<client secret>",
"grant_type": "refresh_token",
"refresh_token": "${refresh_token}"
},
"httpHeaders": {
"Content-Type": "application/x-www-form-urlencoded"
},
"httpContentType": "application/x-www-form-urlencoded",
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"USER_AUTHENTICATION_FAILED",
"PARTNER_AUTHENTICATION_FAILED",
"AuthenticationFailed"
],
"refreshType": "RefreshToken",
"refreshTokenResponsePath": "refresh_token",
"refreshToken": "<refresh token>",
"timeOutError": "Read timed out",
"errorPath": "errorCode",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Bearer",
"retryFailureStatusCode": [
401
],
"accessToken": "Bearer <token>"
}
}
}

 

pborah
Regular Contributor
Regular Contributor

Thank you for the reply.  We have a dynamic token in this case and not static and considering that I will test this using the above script shared by you and will update you with the results.

The above token shared is a dummy one btw and not the actual token.

Regards,

Pallavi

pborah
Regular Contributor
Regular Contributor

Hi,

I have used the below connection JSON script and I was able to get the token refreshed dynamically. This issue is resolved.

{"authentications":{"userAuth":{"authType":"oauth2","httpHeaders":{"contentType":"application/x-www-form-urlencoded"},"authError":["InvalidAuthenticationToken","AuthenticationFailed","FAILURE","INVALID_SESSION_ID"],"url":"https://test/scim2/Token","httpMethod":"POST","httpContentType":"application/x-www-form-urlencoded","errorPath":"errors.message","maxRefreshTryCount":5,"tokenResponsePath":"access_token","tokenType":"Bearer","authHeaderName":"Authorization","httpParams":{"refresh_token":"${refresh_token}","username":"test","password":"test","grant_type":"password"},"retryFailureStatusCode":[401,403,500]}}}