How to test REST Message with Bearer Token

Meloper
Kilo Sage

I have create the Auth Profil and get a Token after i click on "GET OAuth Token".
USING CLIENT CRENDENTIALS

But after a click on Test i get the Message 

Meloper_0-1722863099316.png

I Guess the TEST Button does not use the created Token, also i guess that my header is designed for a Script.

Meloper_0-1722863223561.png

 


How i need to adjust the Form that the TEST UI Action will work for that Rest message?
Do i need to copy the TOken hash?

Also it would be nice if someone can show me a script how to request the token and use it

 

thank you

1 ACCEPTED SOLUTION

Meloper
Kilo Sage

The problem was the short validity of my token of 60 seconds, there is a porperty "glide.rest.outbound.oauth_token_expired_threshold" in ServiceNow that a token 60 seconds before expiration date is already invalid, I have set the value to 15 seconds.
No the Test Button works.

View solution in original post

5 REPLIES 5

Mathias Vandend
Mega Sage

Hi,

If you have configured your auth profile correctly and have added it to your rest message all should be fine:

MathiasVandend_0-1722863329208.png

 

If you go to credentials https://<instance>.service-now.com/discovery_credentials_list.do?sysparm_query=&sysparm_view=
and open your credentials, you should be able to use the 'Get OAuth Token' related link to test if your oauth is configured correctly

MathiasVandend_0-1722863656043.png

 

So, i have added the profil to the Rest Message, in the Get Methode, i use:

Meloper_1-1722864786666.png

If i click GetOAuth Token, it create a Token in manage token List. oauth_credential_list
If i open the discovery credentials List, i have to Record matching my Profil

Ankur Bawiskar
Tera Patron
Tera Patron

@Meloper 

if you set the OAuth profile then it should work directly

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

in my case i use 

Meloper_0-1722864738478.png