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 09:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 09:45 AM
From log i can see there is no obj key for accessTokenResponse
Do you have any adivce on this?
postprocessAccessToken: function(accessTokenResponse)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 09:51 AM
accessTokenResponse itself is a obj parameter.
It has to be passed from either business rule or some other place where this script include is called.
can you provide details where you are calling this script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2023 07:18 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.,