src/main/java/com/github/jreddit/oauth/RedditOAuthAgent.java
public synchronized RedditToken tokenAppOnly(boolean confidential) throws RedditOAuthException {
        
        try {
        
            // Set general values of the request
            TokenRequestBuilder builder = OAuthClientRequest
                .tokenProvider(OAuthProviderType.REDDIT)
                .setParameter(PARAM_GRANT_TYPE, confidential ? GRANT_TYPE_CLIENT_CREDENTIALS : GRANT_TYPE_INSTALLED_CLIENT)
                .setClientId(redditApp.getClientID())
                .setClientSecret(redditApp.getClientSecret());
            
            // If it is not acting on behalf of a unique client, a unique device identifier must be generated:
            if (!confidential) {
                builder = builder.setParameter(PARAM_DEVICE_ID, UUID.randomUUID().toString());
            }
            
            // Build the request
            OAuthClientRequest request = builder.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 tokenAppOnly(boolean confidential) throws RedditOAuthException {
        
        try {
        
            // Set general values of the request
            TokenRequestBuilder builder = OAuthClientRequest
                .tokenProvider(OAuthProviderType.REDDIT)
                .setParameter(PARAM_GRANT_TYPE, confidential ? GRANT_TYPE_CLIENT_CREDENTIALS : GRANT_TYPE_INSTALLED_CLIENT)
                .setClientId(redditApp.getClientID())
                .setClientSecret(redditApp.getClientSecret());
            
            // If it is not acting on behalf of a unique client, a unique device identifier must be generated:
            if (!confidential) {
                builder = builder.setParameter(PARAM_DEVICE_ID, UUID.randomUUID().toString());
            }
            
            // Build the request
            OAuthClientRequest request = builder.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>app-only</i> flow).<br>
<br>
Retrieve a token for the <u>application-only</u>, meaning that the
token is <u>not coupled to any user</u>. The token is typically only
<u>valid for a short period of time</u> (at the moment of writing: 1 hour).
After it has expired, the token will no longer work. You must request a <u>new</u>
token in that case. Refreshing an application-only token is not possible.

@param confidential <i>True</i>: confidential clients (web apps / scripts) not acting on
behalf of one or more logged out users. <i>False</i>: installed app types,
and other apps acting on behalf of one or more logged out users.

@return Token (not associated with a user)

@throws RedditOAuthException