Here are the examples of the java api class taken from open source projects.

1. AppEngineCredentials#refreshAccessToken()

View license
   * Refresh the access token by getting it from the App Identity service
public AccessToken refreshAccessToken() throws IOException {
    if (createScopedRequired()) {
        throw new IOException("AppEngineCredentials requires createScoped call before use.");
    GetAccessTokenResult accessTokenResponse = appIdentityService.getAccessToken(scopes);
    String accessToken = accessTokenResponse.getAccessToken();
    Date expirationTime = accessTokenResponse.getExpirationTime();
    return new AccessToken(accessToken, expirationTime);