Hi Team, I am working on ServiceNow to Snowflake OAUTH Connection and at the stage of get oauth token from rest message we are receiving Unauthorized error and in logs we could see the error details as "Exception on redirect flow - invalid_request, M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2022 10:55 PM
Hi Team, I am working on ServiceNow to Snowflake OAUTH Connection and at the stage of get oauth token from rest message we are receiving Unauthorized error and in logs we could see the error details as "Exception on redirect flow - invalid_request, Missing parameters: access_token: no thrown error". We can see the credentials are correct and we are able to login from snowflake console. If anyone previously worked on this type of integration or idea on the connection errors, Please help me in resolving the issue.
- Labels:
-
IntegrationHub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2022 10:57 PM
Can you show the header
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2022 11:00 PM
Hi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 12:36 AM
Hello Bharathi,
Have you got rid of this error?
Thanks,
Khusboo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 12:58 AM - edited 08-01-2023 01:01 AM
Hi @Bharathi Nunna,
Here is the fix :
Add the log statements in the script include "OAuthUtil" and see the response
gs.log("accessTokenResponse.getContentType()===>" +accessTokenResponse.getContentType());
gs.log("accessTokenResponse.getBody()====>" +accessTokenResponse.getBody());
Results:
2019-07-12 12:14:45
Information accessTokenResponse.getContentType()===>null *** Script
2019-07-12 12:14:45
Information accessTokenResponse.getBody()====>{
"access_token" : "123123123123",
"token_type" : "Bearer",
"expires_in" : 86400
}
Here we can see the Content-Type is null, which is throwing the error based on the IF condition in the "OAuthUtil".
Resolution
Comment out the below IF condition can fix the issue:
//if (contentType && contentType.indexOf('application/json') != -1) {
var tokenResponse = (new global.JSON()).decode(accessTokenResponse.getBody());
var paramMap = accessTokenResponse.getparameters();
for (param in tokenResponse)
paramMap.put(param, tokenResponse[param].toString());
//}
To permanently fix the issue you can extend this script include and overwrite this function with these lines commented out OR create a new script include called, for example, "OAuthUtilClient", copy-paste the code from script include "OAuthUtil" and comment out the lines.
REF : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0754270
[or]
By default ServiceNow sends a POST method(NOT GET) to get the token from the OAuth provider. Please ask the token provider to configure the method with POST method instead of GET method.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....