Issue || OAuth - JWT Bearer (Grant Type)

Kingstan M
Kilo Sage

Hello - SN.

 

Followed this doc = OAuth 2.0 credentials for GitHub Apps - JWT (servicenow.com)

Got details from GitHub end.

 

But when i try to refresh token i get this error 

OAuth flow failed. Verify the configurations and try again. Error detail:invalid_request, Missing parameters: access_token
 
I tried to log OAuth Util script 
 
 

 

//* Dont edit this script include. Best practise: Extend this script include and override the functions. 
var OAuthUtil = Class.create();
OAuthUtil.prototype = {
    initialize: function(oauthContext) {
        this.oauthContext = oauthContext;
    },

    interceptRequestParameters: function(requestParamMap) {
        // Add/Modify request parameters if needed
        this.preprocessAccessToken(requestParamMap);
    },

    parseTokenResponse: function(accessTokenResponse) {
        this.postprocessAccessToken(accessTokenResponse);
    },

    preprocessAuthCode: function(requestParamMap) {},

    preprocessAccessToken: function(requestParamMap) {},

    postprocessAccessToken: function(accessTokenResponse) {
        gs.log("kratos_wee accessTokenResponse.getContentType()===>" + accessTokenResponse.getContentType());
        gs.log("kratos_wee accessTokenResponse.getBody()====>" + accessTokenResponse.getBody());
        var contentType = accessTokenResponse.getContentType();
        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());
        }
    },

    type: 'OAuthUtil'
};

 

I see the log over accessTokenResponse --below--

kratos_wee accessTokenResponse.getBody()====>{"message":"A JSON web token could not be decoded","documentation_url":"https://docs.github.com/rest"

kratos_wee accessTokenResponse.getContentType()===>application/json; charset=utf-8

 

Any advice?

 

Note : As per the OAuth 2.0 credentials for GitHub Apps - JWT (servicenow.com) i dont see OAuth API script = OAuthDevOpsGitHubJWTHandler. in the instance.

 

Many thanks.

 
11 REPLIES 11

Ok good question.

But i dont use the OAuthilUtil script in the OAuth entity profile

 

I simply used the OAuthilUtil script and extended it with my custom script (The one i pasted in the question with log statements) for to see the behaiour.

So - I find the accessTokenResponse is empty thus i get this error.

 

But the config is all fine.

I created PEM file from git and used the given commands in the prod.doc to get JKS file.

Given config setup as per the doc.,

 

no_sinc.png

Hi @Kingstan M ,

 

Sorry to trouble you a lot. All your configurations looks fine.

I find one link in servicenow for the error you are getting

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0754270

 

Please verify.

 

 

 

Thanks for your reply - @Bharath Kumar A 

Much appreciated.

 

Well - Exactly the on KB what i referred.

No progress.

sorry @Kingstan M ,

I tried to give my best.

Even after commented out if statement also you are not getting result. It's strange.

Let me try for some other time.

Thanks for your help @Bharath Kumar A 

Much appreciated..