The basic authentication methods do not provide access to the PeopleToken that is created for the initial authentication. Instead, the relevant values are stored in an AuthenticationResult object in the WWClient. However, there may be scenarios where you want to store the PeopleToken in a database or long-term cache. To do this, additional methods have been added to the WWAuthenticationEndpoint class.

If you are storing the PeopleToken somewhere, ensure you properly encrypt the token because it will include all credentials required to run as the user and re-authenticate when the token expires.

You need to pass the Base64 encoded application credentials to the method. The easiest way to do that is to pass the appId and appSecret to a WWClient object and use the getAppCredentials() method. You can then pass those credentials, the initial user token and the scope to use.

public void getToken() throws WWException, UnsupportedEncodingException {
    WWClient client = WWClient.buildClientUserAccess(null, "5c0bf268-c363-4aae-bbec-e2dbebb2fb72", "vKTpM47ST8ME9gQ9iWt_VjknvMCW", null, null);
    String appCredential = client.getAppCredentials();
    WWAuthenticationEndpoint ep = new WWAuthenticationEndpoint();
    PeopleToken token = ep.authorizeUserGetToken(appCredentials, "ricoZt", ";
    WWClient altClient = WWClient.buildClientUserAccessFromToken("5c0bf268-c363-4aae-bbec-e2dbebb2fb72", "vKTpM47ST8ME9gQ9iWt_VjknvMCW", token);

If you're storing the token, you will need to manually refresh and get the updated PeopleToken when it's due to expire.

    public PeopleToken refresh() throws WWException, UnsupportedEncodingException {
        WWAuthenticationEndpoint ep = new WWAuthenticationEndpoint();
        PeopleToken token = ep.authorizeUserRefreshTokenGetToken(appCredentials, token.getRefresh_Token(), token.getScopeAsString());
        return token;