The CreatorCon Call for Content is officially open! Get started here.

Oauth2 access token to be passed as Header for another REST Message

yamunapriya
Tera Contributor

Hello All,

1.We are setting up a new integration with a cloud tool which will create tickets for the issues raised in the tool. The authentication method is Oauth2.0. 
2.We have created a rest message with Authentication type as 'No Authentication' and passed the following parameters as POST message to get the access token :
grant_type=client_credentials&client_id=xxxx&client_secret=xxxxxx&audience=xxx-api
When we test , we are getting the response as 

{"access_token":" xxxxxxxx ","expires_in":86400,"token_type":"Bearer"}

3. We need to update the issues in the cloud tool from service now and the requirement of the tool is to pass the  request header - restMessage.setRequestHeader('Authorization', 'Bearer  ' + accessToken); 

the accessToken is the one which we get from the above rest message. 

Could you please help how to pass the dynamic access token as the request header for the 2nd REST message and also the authentication method to be used for the 2nd REST Message.

 

We need the solution asap as the due date is just 2 days. Thanks in advance. 

 

1 REPLY 1

Tony Chatfield1
Kilo Patron

Hi, I am not sure I have understood your requirement or configuration from your post, but this KB should help you retrieve a token from oauth_credential table.
 Script to retrieve Access and Refresh tokens using GlideOAuthClient libraries - Support and Troubles...