src/main/java/com/github/jreddit/oauth/RedditOAuthAgent.java
public synchronized boolean refreshToken(RedditToken rToken) throws RedditOAuthException {
        
        try {
            
            // Check whether the token can be refreshed
            if (rToken.isRefreshable()) {
            
                // Set general values of the request
                OAuthClientRequest request = OAuthClientRequest
                    .tokenProvider(OAuthProviderType.REDDIT)
                    .setGrantType(GrantType.REFRESH_TOKEN)
                    .setRefreshToken(rToken.getRefreshToken())
                    .buildBodyMessage();
                
                // Add the user agent
                addUserAgent(request);
                
                // Add basic authentication
                addBasicAuthentication(request, redditApp);
                
                // Return a wrapper controlled by jReddit
                rToken.refresh(oAuthClient.accessToken(request));
                
                return true;
            
            } else {
                
                // The token cannot be refreshed
                return false;
                
            }
        
        
        } catch (OAuthSystemException oase) {
            throw new RedditOAuthException(oase);
        } catch (OAuthProblemException oape) {
            throw new RedditOAuthException(oape);
        }
        
    }
public synchronized boolean refreshToken(RedditToken rToken) throws RedditOAuthException {
        
        try {
            
            // Check whether the token can be refreshed
            if (rToken.isRefreshable()) {
            
                // Set general values of the request
                OAuthClientRequest request = OAuthClientRequest
                    .tokenProvider(OAuthProviderType.REDDIT)
                    .setGrantType(GrantType.REFRESH_TOKEN)
                    .setRefreshToken(rToken.getRefreshToken())
                    .buildBodyMessage();
                
                // Add the user agent
                addUserAgent(request);
                
                // Add basic authentication
                addBasicAuthentication(request, redditApp);
                
                // Return a wrapper controlled by jReddit
                rToken.refresh(oAuthClient.accessToken(request));
                
                return true;
            
            } else {
                
                // The token cannot be refreshed
                return false;
                
            }
        
        
        } catch (OAuthSystemException oase) {
            throw new RedditOAuthException(oase);
        } catch (OAuthProblemException oape) {
            throw new RedditOAuthException(oape);
        }
        
    }
Refresh token.<br>
<br>
This is <u>only</u> possible for tokens retrieved through the <u>code flow</u>
authorization and had their duration set to permanent. Tokens that do not have
a refresh_token with them or are expired, will not be able to be refreshed.
In that case, a new one must be acquired.

@param rToken Reddit token (which needs to be refreshed)

@return Whether the token was successfully refreshed

@throws RedditOAuthException

@see RedditToken#isRefreshable()