public void refreshToken ( ) throws OAuthSystemException , OAuthProblemException { cleanError ( ) ; if ( accessToken == null || refreshToken == null ) { throw new OAuthRuntimeException ( "Access token ot Refresh token not provided" ) ; } OneloginURLConnectionClient httpClient = new OneloginURLConnectionClient ( ) ; OAuthClientRequest request = OAuthClientRequest . tokenLocation ( settings . getURL ( Constants . TOKEN_REFRESH_URL ) ) . buildBodyMessage ( ) ; Map < String , String > headers = new HashMap < String , String > ( ) ; headers . put ( OAuth . HeaderType . CONTENT_TYPE , OAuth . ContentType . JSON ) ; headers . put ( "User-Agent" , this . userAgent ) ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( "grant_type" , GrantType . REFRESH_TOKEN ) ; params . put ( "access_token" , accessToken ) ; params . put ( "refresh_token" , refreshToken ) ; String body = JSONUtils . buildJSON ( params ) ; request . setBody ( body ) ; updateTokens ( httpClient , request , headers ) ; }
Refreshing tokens provides a new set of access and refresh tokens .