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

Bharathi Nunna
ServiceNow Employee
ServiceNow Employee

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.

4 REPLIES 4

suvro
Mega Sage
Mega Sage

Can you show the header

Bharathi Nunna
ServiceNow Employee
ServiceNow Employee

Hi @suvro , I am trying from rest message related link with oauth profile. FYI, i am able to receive the token from postman with same configurations. Let me know if you want to verify application registry details.

Hello Bharathi,

 

Have you got rid of this error?

 

Thanks,

Khusboo

Sohail Khilji
Kilo Patron
Kilo Patron

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.

 

REFhttps://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....

LinkedIn - Lets Connect