Issue || OAuth - JWT Bearer (Grant Type)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 12:44 AM
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
//* 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 07:22 PM
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.,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 07:54 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 08:00 PM
Thanks for your reply - @Bharath Kumar A
Much appreciated.
Well - Exactly the on KB what i referred.
No progress.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 08:07 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 08:28 PM
Thanks for your help @Bharath Kumar A
Much appreciated..