GlideOAuthClientRequest - setRefreshToken(String refreshToken)

Sets the refresh token with the string you provide.

Table 1. Parameters
Name Type Description
refreshToken String The refresh token.
Table 2. Returns
Type Description
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());