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.

Use Access Token on the header of Rest Message Call

VINCENZOBAS
Tera Expert

Hi All,

I need to set on the header of a Rest message a variable that store the AccessToken.
Now, that value is stored on the table "oauth_credential", in the field "token_received" that is a "password2" field.

 

I have thinked to a script that using the GlideEncrypter recover this information,

but, there are a standard way to recover the token  and so use it on the Rest Call?

 

Regads

Vincenzo

1 REPLY 1

Anand Kumar P
Tera Patron

Hi @VINCENZOBAS ,

Try with below script

var OAuthClient = new GlideRecord('u_oauth_client');
if (OAuthClient.get('c09a2bd60fccf6008e2a4b9ce1050e56'))   {
  var encrypter = new GlideEncrypter();
  var clientSecret = encrypter.decrypt(OAuthClient.u_secret);
  gs.print(clientSecret);
}

Thanks,

Anand