Smartsheet Oauth2.0 GlideOAuthStringMap

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2020 05:38 AM
Hello,
I am tying to integrate the Smartsheet application with servicenow using Oauth2.0 token. The issue i am facing is the the keyword in authorization code that the smartsheet is sending is not of access_token but of code example: https://<myinst>.com/oauth_redirect.do?code=dlhmqzuefidheafy&expires_in=599928&state=483270143
as per the "Live Coding Happy Hour" on youtube https://www.youtube.com/watch?v=6KPhLYIDchU i created a custom Script include to fetch the accesstoken response, but i am not able to the the parameters as per the video. The only function that is being called is the "preprocessAuthCode" but the arguments passed to is empty and the log shows as [object GlideOAuthStringMap], not able to find the documentation to it. Could anyone help with me parsing the parameters
below is the Script include i have written
var OAuthJSSmartSheet = Class.create();
OAuthJSSmartSheet.prototype = {
initialize: function() {
gs.info("testing init");
},
interceptRequestParameters: function(requestParamMap) {
// Add/Modify request parameters if needed
gs.info("testing interceptRequestParameters="+requestParamMap.toString());
this.preprocessAccessToken(requestParamMap);
},
parseTokenResponse: function(accessTokenResponse) {
gs.info("testing parseTokenResponse="+accessTokenResponse.toString());
try {
this.postprocessAccessToken(accessTokenResponse);
} catch (e) {
gs.info(e);
}
},
preprocessAuthCode: function(requestParamMap) {
gs.info("preprocessAuthCode=" + requestParamMap);
// gs.info("preprocessAuthCode=" + requestParamMap.getBody());
// gs.info("preprocessAuthCode=" + requestParamMap.getparameters());
// gs.info("preprocessAuthCode=" + requestParamMap.getContentType());
},
preprocessAccessToken: function(requestParamMap) {
gs.info("testing preprocessAccessToken=" + requestParamMap);
},
postprocessAccessToken: function(accessTokenResponse) {
gs.info("testing postprocessAccessToken=" + accessTokenResponse);
var contentType = accessTokenResponse.getContentType();
var contentBody = accessTokenResponse.getBody();
gs.info("testing=" + contentType);
gs.info("testing=" + 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());
}*/
},
type: 'OAuthJSSmartSheet'
};
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2020 02:00 AM
Hey, did you get anywhere with this?
I was hoping to be able to modify my request to change the client_id in a client_credentials flow at run time.
I get the same thing for requestParamMap... eg nothing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2020 11:05 AM
nope, trying hard. Also do check for Scopes in your case it might work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2020 03:40 AM
Hello.
The results of my research and analysis are as follows.
//Analysis results
object GlideOAuthStringMap
function constructor
function get
function getKeys
function isScopedObject
function put
function remove
//Example
var strKeys = ''+requestParamMap.getKeys();
if(strKeys){
var keys = strKeys.split(',');
for(var i = 0; i < keys.length; i++){
gs.info(''+keys[i]+': '+ requestParamMap.get(keys[i]));
//requestParamMap.put(keys[i],value);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2020 03:55 AM
var paramMap = accessTokenResponse.getparameters();
paramMap is "GlideOAuthStringMap".