---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideOAuthClientRequest - Scoped, Global

# GlideOAuthClientRequest - Scoped, Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

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.

## GlideOAuthClientRequest - getGrantType() {#ariaid-title2}

Retrieves the grant type.
{#r_GlideOAuthClientRequestGetGrantType__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 1. Parameters]

{#r_GlideOAuthClientRequestGetGrantType__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestGetGrantType__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | The grant type. |
[Table 2. Returns]

{#r_GlideOAuthClientRequestGetGrantType__table_rc4_bzf_cr}

## GlideOAuthClientRequest - getHeader(String name) {#ariaid-title3}

Retrieves the HTTP headers for the string you provide.
{#r_GlideOAuthClientRequestGetHeader__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | The name of the parameter. |
[Table 3. Parameters]

{#r_GlideOAuthClientRequestGetHeader__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestGetHeader__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| StringMap | The string map with the HTTP headers. |
[Table 4. Returns]

{#r_GlideOAuthClientRequestGetHeader__table_rc4_bzf_cr}

## GlideOAuthClientRequest - getHeaders() {#ariaid-title4}

Retrieves the HTTP headers.
{#r_GlideOAuthClientRequestGetHeaders__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 5. Parameters]

{#r_GlideOAuthClientRequestGetHeaders__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestGetHeaders__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| StringMap | The string map with the HTTP headers. |
[Table 6. Returns]

{#r_GlideOAuthClientRequestGetHeaders__table_rc4_bzf_cr}

## GlideOAuthClientRequest - getParameter(String name) {#ariaid-title5}

Retrieves the parameters for the parameter name you provide.
{#r_GlideOAuthClientRequestGetParameter__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | The parameter name for which you want the parameters. |
[Table 7. Parameters]

{#r_GlideOAuthClientRequestGetParameter__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestGetParameter__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | The parameters. |
[Table 8. Returns]

{#r_GlideOAuthClientRequestGetParameter__table_rc4_bzf_cr}

## GlideOAuthClientRequest - getPassword() {#ariaid-title6}

Retrieves the password.
{#r_GlideOAuthClientRequestGetPassword__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 9. Parameters]

{#r_GlideOAuthClientRequestGetPassword__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestGetPassword__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | The password. |
[Table 10. Returns]

{#r_GlideOAuthClientRequestGetPassword__table_rc4_bzf_cr}

## GlideOAuthClientRequest - getRefreshToken() {#ariaid-title7}

Retrieves the refresh token.
{#r_GlideOAuthClientRequestGetRefreshToken__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 11. Parameters]

{#r_GlideOAuthClientRequestGetRefreshToken__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestGetRefreshToken__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | The refresh token. |
[Table 12. Returns]

{#r_GlideOAuthClientRequestGetRefreshToken__table_rc4_bzf_cr}

## GlideOAuthClientRequest - getScope() {#ariaid-title8}

Retrieves the scope.
{#r_GlideOAuthClientRequestGetScope__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 13. Parameters]

{#r_GlideOAuthClientRequestGetScope__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestGetScope__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | The scope. |
[Table 14. Returns]

{#r_GlideOAuthClientRequestGetScope__table_rc4_bzf_cr}

## GlideOAuthClientRequest - getUserName() {#ariaid-title9}

Retrieves the user name.
{#r_GlideOAuthClientRequestGetUserName__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| none |   |   |
[Table 15. Parameters]

{#r_GlideOAuthClientRequestGetUserName__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestGetUserName__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| String | The user name. |
[Table 16. Returns]

{#r_GlideOAuthClientRequestGetUserName__table_rc4_bzf_cr}

## GlideOAuthClientRequest - setGrantType(String grantType) {#ariaid-title10}

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.
{#r_GlideOAuthClientRequestSetGrantType__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | The grant type. |
[Table 17. Parameters]

{#r_GlideOAuthClientRequestSetGrantType__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestSetGrantType__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 18. Returns]

{#r_GlideOAuthClientRequestSetGrantType__table_rc4_bzf_cr}

## GlideOAuthClientRequest - setHead(String name, String value) {#ariaid-title11}

Retrieves the HTTP headers for the string you provide.
{#r_GlideOAuthClientRequestSetHead__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | The name of the parameter. |
| value | String | The value of the parameter. |
[Table 19. Parameters]

{#r_GlideOAuthClientRequestSetHead__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestSetHead__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 20. Returns]

{#r_GlideOAuthClientRequestSetHead__table_rc4_bzf_cr}

## GlideOAuthClientRequest - setParameter(String name, String value) {#ariaid-title12}

Sets the parameters for the name:value pair of strings you provide.
{#r_GOACR-SetParameters_N_V__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | The parameter name for which you want the parameters. |
| value | String | The value of the parameter. |
[Table 21. Parameters]

{#r_GOACR-SetParameters_N_V__table_qc4_bzf_cr} {#r_GOACR-SetParameters_N_V__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 22. Returns]

{#r_GOACR-SetParameters_N_V__table_rc4_bzf_cr}

## GlideOAuthClientRequest - setPassword(String password) {#ariaid-title13}

Sets the password with the string you provide.
{#r_GlideOAuthClientRequestSetPassword__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| password | String | The user name. |
[Table 23. Parameters]

{#r_GlideOAuthClientRequestSetPassword__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestSetPassword__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 24. Returns]

{#r_GlideOAuthClientRequestSetPassword__table_rc4_bzf_cr}

## GlideOAuthClientRequest - setRefreshToken(String refreshToken) {#ariaid-title14}

Sets the refresh token with the string you provide.
{#r_GlideOAuthClientRequestSetRefreshToken__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| refreshToken | String | The refresh token. |
[Table 25. Parameters]

{#r_GlideOAuthClientRequestSetRefreshToken__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestSetRefreshToken__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 26. Returns]

{#r_GlideOAuthClientRequestSetRefreshToken__table_rc4_bzf_cr}  
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) {#ariaid-title15}

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.
{#r_GlideOAuthClientRequestSetScope__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| scope | String | The scope. |
[Table 27. Parameters]

{#r_GlideOAuthClientRequestSetScope__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestSetScope__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 28. Returns]

{#r_GlideOAuthClientRequestSetScope__table_rc4_bzf_cr}

## GlideOAuthClientRequest - setUserName(String userName) {#ariaid-title16}

Sets the user name with the string you provide.
{#r_GlideOAuthClientRequestSetUserName__table_qc4_bzf_cr__entry__3}

| Name | Type | Description |
|-|-|-|
| userName | String | The user name. |
[Table 29. Parameters]

{#r_GlideOAuthClientRequestSetUserName__table_qc4_bzf_cr} {#r_GlideOAuthClientRequestSetUserName__table_rc4_bzf_cr__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 30. Returns]

{#r_GlideOAuthClientRequestSetUserName__table_rc4_bzf_cr}

