GlideOAuthClient - requestToken(String clientName, String jsonString)

Retrieves the token for the client, with the request parameters encoded in JSON format.

Table 1. Parameters
Name Type Description
clientName String The client name.
jsonString String The JSON string for the client.
Table 2. Returns
Type Description
GlideOAuthClientResponse The token for the client.

This example shows a resource owner password grant type request, with request parameters encoded in JSON format.

var oAuthClient = new GlideOAuthClient();
var params ={grant_type:"password", username:"itil", password:'itil'};
var json =new JSON();
var text = json.encode(params);
var tokenResponse = oAuthClient.requestToken('TestClient', text);
var token = tokenResponse.getToken();

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