- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 11:21 PM
Below script is used to retrieve access token and refresh token for oauth.
var oAuthClient = new sn_auth.GlideOAuthClient();
var params = {
'grant_type': 'client_credentials',
'client_id': 'abc',
'client_secret': '123'
};
var json = new global.JSON();
var text = json.encode(params);
var tokenResponse = oAuthClient.requestToken('ABC', text);
var token = tokenResponse.getToken();
gs.print("AccessToken:" + token.getAccessToken());
gs.print("AccessTokenExpiresIn:" + token.getExpiresIn());
gs.print("RefreshToken:" + token.getRefreshToken());
But error message is shown as below
OAuthProblemException{error='invalid_request', description='Multiple client credentials cannot be specified.', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}}
*** Script: AccessToken:null
*** Script: AccessTokenExpiresIn:0
*** Script: RefreshToken:null
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 01:59 AM
Hi @Sruthe ,
The error message "Multiple client credentials cannot be specified" suggests that the client_id and client_secret parameters are being specified twice in the request. One possible reason for this error could be that the ABC parameter being passed to the oAuthClient.requestToken() method is supposed to be the name of an OAuth configuration record in ServiceNow, and it may be including the client_id and client_secret parameters already.
To fix this issue, you can modify the params object to only include the grant_type parameter, like this:
var params = {
'grant_type': 'client_credentials'
};
Then, update the oAuthClient.requestToken() method call to pass the client_id and client_secret parameters directly as arguments:
var tokenResponse = oAuthClient.requestToken('abc', '123', 'ABC', params);
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 01:59 AM
Hi @Sruthe ,
The error message "Multiple client credentials cannot be specified" suggests that the client_id and client_secret parameters are being specified twice in the request. One possible reason for this error could be that the ABC parameter being passed to the oAuthClient.requestToken() method is supposed to be the name of an OAuth configuration record in ServiceNow, and it may be including the client_id and client_secret parameters already.
To fix this issue, you can modify the params object to only include the grant_type parameter, like this:
var params = {
'grant_type': 'client_credentials'
};
Then, update the oAuthClient.requestToken() method call to pass the client_id and client_secret parameters directly as arguments:
var tokenResponse = oAuthClient.requestToken('abc', '123', 'ABC', params);
Thanks,
Ratnakar