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

REST Connection is failing after few hours

jagadeeshdoma
New Contributor III
New Contributor III

Hello,

We've encountered an issue with our REST connection—it begins to fail after a few hours. Our analysis suggests that the root cause may be the connection's inability to retrieve an updated status token once the initial token expires. We also suspect that although we receive a token failure in the response payload after expiration, the response code remains 200.

We're seeking assistance in resolving this matter.

Below is the JSON configuration for the connection:

 

 

{
  "authentications": {
    "userAuth": {
      "authType": "oauth2",
      "url": "https://<appurl>/token",
      "httpMethod": "POST",
      "httpParams": {
        "applicationId": "<id>"
      },
      "httpHeaders": {
        "contentType": "application/json"
      },
      "httpContentType": "application/json",
      "expiryError": "107",
      "authError": [
        "InvalidAuthenticationToken",
        "AuthenticationFailed",
        "FAILURE",
        "INVALID_SESSION_ID"
      ],
	   "retryFailureStatusCode": [
            500,503,502,501,504,400,401,403
         ],
      "timeOutError": "Read timed out",
      "errorPath": "error.code",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "data.accessToken",
      "tokenType": "Bearer",
      "accessToken": "Bearer abc",
      "testConnectionParams": {
        "http": {
          "url": "https://<appurl>/token",
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/json",
          "httpMethod": "GET"
        },
        "successResponses": {
		  "isSuccessful":true
		},
		 "unsuccessResponses": {
		  "isSuccessful":false
		},
        "errors": ["Couldn't authenticate you"],
        "errorPath": "error"
      }
    }
  }
}

 

 

Below is the response we received for the authentication API from the application:

Response status code is 200

 

 

{
    "pipelineId": null,
    "stationId": null,
    "code": 107,
    "message": "Token has expired. Please login again",
    "isSuccessful": false,
    "data": null
}

 

 

 

Regards,

Jagadeesh

14 REPLIES 14

rushikeshvartak
All-Star
All-Star

It seems app is using refresh token 

Share 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.

jagadeeshdoma
New Contributor III
New Contributor III

Hi @rushikeshvartak ,

Below is the curl command for the same:

curl --location 'https://<app_url>/token' \
--header 'Content-Type: application/json' \
--data '{
"applicationId" : "<app_id>"
}'

Response:
{
"pipelineId": null,
"stationId": null,
"code": 0,
"message": "The operation completed successfully.",
"isSuccessful": true,
"data": {
"accessToken": "<access_token_value>",
"refreshToken": "<refresh_token_value>"
}
}

{
  "authentications": {
    "userAuth": {
      "authType": "oauth2",
      "url": "https://<appurl>/token",
      "httpMethod": "POST",
      "httpParams": {
        "applicationId": "<id>"
      },
      "httpHeaders": {
        "contentType": "application/json"
      },
      "httpContentType": "application/json",
      "expiryError": "107",
      "authError": [
        "InvalidAuthenticationToken",
        "AuthenticationFailed",
        "FAILURE",
        "INVALID_SESSION_ID"
      ],
	   "retryFailureStatusCode": [
            500,503,502,501,504,400,401,403
         ],
      "timeOutError": "Read timed out",
      "errorPath": "error.code",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "accessToken",
      "tokenType": "Bearer",
      "accessToken": "Bearer abc",
      "testConnectionParams": {
        "http": {
          "url": "https://<appurl>/token",
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/json",
          "httpMethod": "GET"
        },
        "successResponses": {
		  "isSuccessful":true
		},
		 "unsuccessResponses": {
		  "isSuccessful":false
		},
        "errors": ["Couldn't authenticate you"],
        "errorPath": "error"
      }
    }
  }

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

jagadeeshdoma
New Contributor III
New Contributor III

Hi @rushikeshvartak ,

The Test connection parameters you have provided won't work as this api returns 404 error as GET command is not available for this endpoint.

"http": {
          "url": "https://<appurl>/token",
          "httpHeaders": {
            "Authorization": "${access_token}"
          },
          "httpContentType": "application/json",
          "httpMethod": "GET"
        }

 I also tested updating the connection params and the connection is failing with the JSON you provided.

remove test connection param and try import


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

jagadeeshdoma
New Contributor III
New Contributor III

I've already attempted that approach, and the connection remains successful. However, the issue persists with the import process failing after a few hours, indicating that the connection eventually encounters problems. It's worth noting that this issue doesn't manifest during the test connection because the test connection parameters aren't present in that scenario.

What is validity of token


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

jagadeeshdoma
New Contributor III
New Contributor III

Token lifetime is 8 hours

Regards,

Jagadeesh

Does application support refresh token ?


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

jagadeeshdoma
New Contributor III
New Contributor III

Hi @rushikeshvartak ,

The application supports refresh token. Could you please help with the Connect account JSON using the details below.

Below are the API's supported for the application authentication:

1. Request Access Token API:
a. Request:

curl --location 'https://<application_instance_name>/api/common/external-application-token/token' \
--header 'Content-Type: application/json' \
--data '{
"applicationId" : "<application_id>"
}'

b. Response

{
"pipelineId": null,
"stationId": null,
"code": 0,
"message": "The operation completed successfully.",
"isSuccessful": true,
"data": {
"accessToken": "<access_token>",
"refreshToken": "<refresh_token>"
}
}

 

2. Request Access Token using refresh token API:

a. Request:

curl --location 'https://<application_instance_name>/api/common/external-application-token/refresh-token' \
--header 'refresh_token: <refresh_token>' \
--header 'Content-Type: application/json' \
--data '{
"applicationId" : "<application_id>"
}'

b. Response:

{
"pipelineId": null,
"stationId": null,
"code": 0,
"message": "The operation completed successfully.",
"isSuccessful": true,
"data": {
"accessToken": "<access_token>",
"refreshToken": "<refresh_token>"
}
}

 

Regards,

Jagadeesh

Refer https://docs.saviyntcloud.com/bundle/REST-v24x/page/Content/Examples-for-JSON-Construction.htm


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

jagadeeshdoma
New Contributor III
New Contributor III

Hi @rushikeshvartak ,

I tried creating the JSON but it is giving connection failure. Also, i am just curious that the API always returns '200' response status code, even when API is failing. It returns error in response payload. Is it affecting the Connection retry not happening after few hours?
Below is the constructed JSON

 

{
    "authentications": {
        "userAuth": {
            "authType": "oauth2",
            "url": "https://removed/api/common/external-application-token/token",
            "httpMethod": "POST",
            "httpParams": {
                "applicationId": "3c79e108-c834-47d3-b916-b25f41132f84"
            },
            "httpHeaders": {
                "contentType": "application/json"
            },
            "httpContentType": "application/json",
            "expiryError": "ExpiredAuthenticationToken",
            "authError": [
                "InvalidAuthenticationToken",
                "AuthenticationFailed",
                "FAILURE",
                "INVALID_SESSION_ID"
            ],
            "retryFailureStatusCode": [
                500,
                503,
                502,
                501
            ],
            "timeOutError": "Read timed out",
            "errorPath": "errors.type",
            "maxRefreshTryCount": 5,
            "tokenResponsePath": "data.accessToken",
            "refreshType": "RefreshToken",
            "tokenType": "Bearer",
            "accessToken": "Bearer abc",
            "refreshToken": "<>",
            "refreshTokenAuthError": [
                "Unable to retrieve SAML assertion",
                "The provided SAML assertion is expired"
            ],
            "refreshTokenErrorPath": "errorMessage",
            "refreshTokenCall": {
                "refreshTokenResponsePath": "data.refreshToken",
                "url": "https://removed/api/common/external-application-token/refresh-token",
                "httpMethod": "POST",
                "httpParams": {
                    "applicationId": "3c79e108-c834-47d3-b916-b25f41132f84",
					"Refresh_token": "${refresh_token}"
                },
                "httpHeaders": {
                    "Content-Type": "application/json"
                },
                "httpContentType": "application/json"
            },
            "testConnectionParams": {
                "http": {
                    "url": "https://removed/api/notification/internal-integration/get-list-of-roles",
                    "httpHeaders": {
                        "Authorization": "${access_token}"
                    },
                    "httpContentType": "application/json",
                    "httpMethod": "GET"
                },
                "successResponses": {
                    "isSuccessful": true
                },
                "unsuccessResponses": {
                    "isSuccessful": false
                },
                "errors": [
                    "Couldn't authenticate you"
                ],
                "errorPath": "error"
            }
        }
    }
}

[This message has been edited by moderator to mask url]

 

jagadeeshdoma
New Contributor III
New Contributor III

Hi @rushikeshvartak ,

Do you have any approach to debug this further?

Regards,

Jagadeesh

Can you share logs


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