ServiceNow
An IT, customer, and employee Customer Relationship Management platform.
References
Connect ServiceNow to GitHub account
I created a developer app connection configuration in GitHub
- https://github.com/settings/apps/servicenow-dev
- Saved private key to personal computer (Dell 14)
ServiceNow OAuth setup
I’m working through these steps: https://docs.servicenow.com/bundle/paris-devops/page/product/enterprise-dev-ops/concept/dev-ops-github-apps-oauth-auth.html
In the ‘Register GitHub as an OAuth Provider (Authorization Code)’ section, there is a reference to ‘OAuthDevOpsGitHubHandler’, which doesn’t exist in my SN developer instance. I’m kind of stuck at that point. I don’t know if I can use an existing script include (System UI → Script Includes - search for *Oath) or what I would include in a new script include. I tried selecting another oath script include but authentication to my GitHub app fails.
This page may have some useful information: https://developer.servicenow.com/blog.do?p=/post/live-coding-happy-hour-recap-for-march-10-2017-oauth-part-3-github-api-and-one-token-per-user/
- At 21:40, they cover the equivalent script include.
var OAuthGitHubHandler = Class.create();
OAuthGitHubHandler.prototype = {
initialize: function() {},
interceptRequestParameters: function(requestParamMap) {
// Add/Modify request parameters if needed
this.preprocessAccessToken(requestParamMap);
},
parseTokenResponse: function(accessTokenResponse) {
this.postprocessAccessToken(accessTokenResponse);
},
preprocessAuthCode: function(requestParamMap) {},
preprocessAccessToken: function (requestParamMap) {
gs.info('preprocessing');
},
postprocessAccessToken: function(accessTokenResponse) {
var contentType = accessTokenResponse.getContentType();
var contentBody = accessTokenResponse.getBody();
var paramMap = accessTokenResponse.getparameters();
var params = contentBody.split('&');
var parts;
params.forEach(function(param) {
parts = param.split('=');
gs.info('key=' + parts[0] + ', value=' + parts[1]);
paramMap.put(parts[0], parts[1]);
});
gs.info('contentType: ' + contentType);
gs.info('contentBody: ' + contentBody);
/*
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();
}
}
*/
paramMap.put('expires_in', '365246060');
},
type: 'OAuthUtil'
};