Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Sending additional parameters to the OAuth Provider to retrive the access and refresh tokens using GlideOAuthClient() - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Sending additional parameters to the OAuth Provider to retrive the access and refresh tokens using GlideOAuthClient()
KB0743846

Sending additional parameters to the OAuth Provider to retrive the access and refresh tokens using GlideOAuthClient()


1795 Views Last updated : Apr 7, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

Description

 Some OAuth providers require additional parameters to be sent in addition to standard parameters (grant_type,username, password , client_id , client_secret ) to issue access token and refresh token . This article explains how to send any additional parameters from the script .

Procedure

0) Create the OAuth Provider record in ServiceNow instance with all the required values .

1) In the script , create a params string and include any additional parameters that the OAuth Provider expects .

2) For example if a parameter called "resource" needs to be sent , include it the the params variable .

3) Below is a sample code .

var oAuthClient = new sn_auth.GlideOAuthClient(); 
var requestor_context = 'test'; 
var requestor_id = 'abc@xyz.com'; 
var oauth_profile_id = '<sys_od_of_oauth_profile>'; 

var params = {grant_type:'password', username:'abc@abc.com', password:'pa$$word', resource:'123-123-123', oauth_requestor_context:requestor_context, oauth_requestor:requestor_id, oauth_provider_profile:oauth_profile_id}; 

var json = new global.JSON(); 
var text = json.encode(params); 
var tokenResponse = oAuthClient.requestToken('<OAuth_Profile_Name>', text); 
var token = tokenResponse.getToken(); 
var access_token = token.getAccessToken() ; 

gs.log("AccessToken:" + access_token); 
gs.log("AccessTokenExpiresIn:" + token.getExpiresIn()); 
gs.log(" RefreshToken:" + token.getRefreshToken());

Applicable Versions

All versions .


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.