Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

GlideOAuthClientRequest - Scoped, Global

The GlideOAuthClientRequest API provides methods for handling OAuth client requests.

You can use this API in global and scoped scripts. In scoped scripts use the sn_auth namespace identifier.

Parent Topic:Server API reference

GlideOAuthClientRequest - getGrantType()

Retrieves the grant type.

NameTypeDescription
none  
TypeDescription
StringThe grant type.

GlideOAuthClientRequest - getHeader(String name)

Retrieves the HTTP headers for the string you provide.

NameTypeDescription
nameStringThe name of the parameter.
TypeDescription
StringMapThe string map with the HTTP headers.

GlideOAuthClientRequest - getHeaders()

Retrieves the HTTP headers.

NameTypeDescription
none  
TypeDescription
StringMapThe string map with the HTTP headers.

GlideOAuthClientRequest - getParameter(String name)

Retrieves the parameters for the parameter name you provide.

NameTypeDescription
nameStringThe parameter name for which you want the parameters.
TypeDescription
StringThe parameters.

GlideOAuthClientRequest - getPassword()

Retrieves the password.

NameTypeDescription
none  
TypeDescription
StringThe password.

GlideOAuthClientRequest - getRefreshToken()

Retrieves the refresh token.

NameTypeDescription
none  
TypeDescription
StringThe refresh token.

GlideOAuthClientRequest - getScope()

Retrieves the scope.

NameTypeDescription
none  
TypeDescription
StringThe scope.

GlideOAuthClientRequest - getUserName()

Retrieves the user name.

NameTypeDescription
none  
TypeDescription
StringThe user name.

GlideOAuthClientRequest - setGrantType(String grantType)

Sets the grant type for the string you provide.

Note: You only need to set the grant type if it is not already defined in the OAuth provider profile.

NameTypeDescription
nameStringThe grant type.
TypeDescription
void 

GlideOAuthClientRequest - setHead(String name, String value)

Retrieves the HTTP headers for the string you provide.

Note: setHead(String name, String value) is used in global. The scoped equivalent of this method is setHeader(String name, String value).

NameTypeDescription
nameStringThe name of the parameter.
valueStringThe value of the parameter.
TypeDescription
void 

GlideOAuthClientRequest - setParameter(String name, String value)

Sets the parameters for the name:value pair of strings you provide.

NameTypeDescription
nameStringThe parameter name for which you want the parameters.
valueStringThe value of the parameter.
TypeDescription
void 

GlideOAuthClientRequest - setPassword(String password)

Sets the password with the string you provide.

NameTypeDescription
passwordStringThe user name.
TypeDescription
void 

GlideOAuthClientRequest - setRefreshToken(String refreshToken)

Sets the refresh token with the string you provide.

NameTypeDescription
refreshTokenStringThe refresh token.
TypeDescription
void 

This example shows a resource owner password grant type request.

     var tokenRequest =new GlideOAuthClientRequest();
     tokenRequest.setGrantType("password");
     tokenRequest.setUserName("itil");
     tokenRequest.setPassword("itil");
     tokenRequest.setScope(null);

     var oAuthClient =new GlideOAuthClient();var tokenResponse = oAuthClient.requestToken("TestClient", tokenRequest);
     gs.log("Error:"+ tokenResponse.getErrorMessage());

     var token = tokenResponse.getToken();if(token){
       gs.log("AccessToken:"+ token.getAccessToken());
       gs.log("AccessTokenExpiresIn:"+ token.getExpiresIn());
       gs.log("RefreshToken:"+ token.getRefreshToken());

This example shows a refresh token grant type request.

     var tokenRequest =new GlideOAuthClientRequest();
     tokenRequest.setGrantType("refresh_token");
     tokenRequest.setRefreshToken("N-GtdSVLkWP_Cr-TysXdmNy59ZYafu5ZzAS4YaSluXDm0kCkInEnu-hwM5SsGYSFwKJ6xauVmoaq7xJNoalXFQ");
     tokenRequest.setScope(null);

     var oAuthClient =new GlideOAuthClient();
     tokenResponse = oAuthClient.requestToken("TestClient", tokenRequest);
     gs.log("Error:"+ tokenResponse.getErrorMessage());
     token = tokenResponse.getToken();if( token){
        gs.log("AccessToken:"+ token.getAccessToken());
        gs.log("AccessTokenExpiresIn:"+ token.getExpiresIn());
        gs.log("AccessTokenSysID:"+ token.getAccessTokenSysID());
        gs.log("RefreshToken:"+ token.getRefreshToken());
        gs.log("RefreshTokenSysID:"+ token.getRefreshTokenSysID());

GlideOAuthClientRequest - setScope(String scope)

Sets the scope for the string you provide.

Note: You only need to set the scope if it is not already defined in the OAuth provider.

NameTypeDescription
scopeStringThe scope.
TypeDescription
void 

GlideOAuthClientRequest - setUserName(String userName)

Sets the user name with the string you provide.

NameTypeDescription
userNameStringThe user name.
TypeDescription
void