Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to generate token url in application registry?

VS
Giga Guru

Hi All,

We need to provide a token url to the client.

How can we generate a token url?

Thanks,

Veer

2 REPLIES 2

Raghu Ram Y
Kilo Sage

Hello @VS 

Use the below code to generate tokens

function dumpToken(token) {
  if(token) {
     gs.info("AccessToken:" + token.getAccessToken());
     gs.info("AccessTokenExpiresIn:" + token.getExpiresIn());
     gs.info("RefreshToken:" + token.getRefreshToken());
  }
}

var oAuthClient = new  sn_auth.GlideOAuthClient();
var token = oAuthClient.getToken('Request ID from the OAuth Requestor Profile', 'OAuth profile ID from the OAuth Entity Profile ');
dumpToken(token);

@VS 

I Hope my solution helps you, if it helps please mark my response as correct and helpful so that it will be helpful for the future readers