src/main/java/com/github/jreddit/oauth/RedditOAuthAgent.java
public synchronized RedditToken token(String code) throws RedditOAuthException {
        
        try {
        
            // Set general values of the request
            OAuthClientRequest request = OAuthClientRequest
                .tokenProvider(OAuthProviderType.REDDIT)
                .setGrantType(GrantType.AUTHORIZATION_CODE)
                .setClientId(redditApp.getClientID())
                .setClientSecret(redditApp.getClientSecret())
                .setRedirectURI(redditApp.getRedirectURI())
                .setParameter(PARAM_CODE, code)
                .buildBodyMessage();
            
            // Add the user agent
            addUserAgent(request);
            
            // Add basic authentication
            addBasicAuthentication(request, redditApp);
            
            // Return a wrapper controlled by jReddit
            return new RedditToken(oAuthClient.accessToken(request));
        
        } catch (OAuthSystemException oase) {
            throw new RedditOAuthException(oase);
        } catch (OAuthProblemException oape) {
            throw new RedditOAuthException(oape);
        }

    }
public synchronized RedditToken token(String code) throws RedditOAuthException {
        
        try {
        
            // Set general values of the request
            OAuthClientRequest request = OAuthClientRequest
                .tokenProvider(OAuthProviderType.REDDIT)
                .setGrantType(GrantType.AUTHORIZATION_CODE)
                .setClientId(redditApp.getClientID())
                .setClientSecret(redditApp.getClientSecret())
                .setRedirectURI(redditApp.getRedirectURI())
                .setParameter(PARAM_CODE, code)
                .buildBodyMessage();
            
            // Add the user agent
            addUserAgent(request);
            
            // Add basic authentication
            addBasicAuthentication(request, redditApp);
            
            // Return a wrapper controlled by jReddit
            return new RedditToken(oAuthClient.accessToken(request));
        
        } catch (OAuthSystemException oase) {
            throw new RedditOAuthException(oase);
        } catch (OAuthProblemException oape) {
            throw new RedditOAuthException(oape);
        }

    }
Token retrieval (<i>code</i> flow).<br>
<br>
Retrieve a token for a specific user, meaning that the token is <u>coupled to a user</u>.
After it has expired, the token will no longer work. You must either request a new
token, or refresh it using {@link #refreshToken(RedditToken)}.

@param code One-time code received from the user, after manual authorization by that user

@return Token (associated with a user)

@throws RedditOAuthException