OAuth authentication for Inbound
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 04:53 AM
I have a script include which calls out of box Service Catalog API (order_now), I want to use oauth authentication in the script to get the token.
I have created OAuth Provider record in application registry and used it in the background script to generate OAuth token, throws error.
Pls help
var oAuthClient = new sn_auth.GlideOAuthClient();
username = 'admin';
password = '123';
params = {
grant_type: "password",
username: username,
password: password
};
var json = new JSON();
var text = json.encode(params);
var tokenResponse = oAuthClient.requestToken('oauth_client1', text); // oauth_client1 is the OAuth provider record in aplication registry)
var token = tokenResponse.getToken();
gs.print("$$$ AccessToken:" + token.getAccessToken());
gs.print("$$$ AccessTokenExpiresIn:" + token.getExpiresIn());
gs.print("$$$ RefreshToken:" + token.getRefreshToken());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 06:44 AM
3rd party wants to consume ServiceNow endpoint using OAuth?
what's your use-case?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader