Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

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