Class UserAuthorizer.TokenResponseWithConfig (1.30.1)

public static class UserAuthorizer.TokenResponseWithConfig

Represents the response from an OAuth token exchange, including configuration details used to initiate the flow.

This response can be used to initialize the following credentials types:


 // UserCredentials when Google is the identity provider:
 UserCredentials userCredentials = UserCredentials.newBuilder()
     .setHttpTransportFactory(tokenResponseWithConfig.getHttpTransportFactory())
     .setClientId(tokenResponseWithConfig.getClientId())
     .setClientSecret(tokenResponseWithConfig.getClientSecret())
     .setAccessToken(tokenResponseWithConfig.getAccessToken())
     .setRefreshToken(tokenResponseWithConfig.getRefreshToken())
     .setTokenServerUri(tokenResponseWithConfig.getTokenServerUri())
     .build();

 // ExternalAccountAuthorizedUserCredentials when using Workforce Identity Federation:
 ExternalAccountAuthorizedUserCredentials externalAccountAuthorizedUserCredentials =
     ExternalAccountAuthorizedUserCredentials.newBuilder()
         .setHttpTransportFactory(tokenResponseWithConfig.getHttpTransportFactory())
         .setClientId(tokenResponseWithConfig.getClientId())
         .setClientSecret(tokenResponseWithConfig.getClientSecret())
         .setAccessToken(tokenResponseWithConfig.getAccessToken())
         .setRefreshToken(tokenResponseWithConfig.getRefreshToken())
         .setTokenUrl(tokenResponseWithConfig.getTokenServerUri().toURL().toString())
         .build();
 

Inheritance

java.lang.Object > UserAuthorizer.TokenResponseWithConfig

Methods

getAccessToken()

public AccessToken getAccessToken()

Returns the access token obtained from the token exchange.

Returns
Type Description
AccessToken

The access token.

getClientId()

public String getClientId()

Returns the OAuth 2.0 client ID used.

Returns
Type Description
String

The client ID.

getClientSecret()

public String getClientSecret()

Returns the OAuth 2.0 client secret used.

Returns
Type Description
String

The client secret.

getHttpTransportFactory()

public HttpTransportFactory getHttpTransportFactory()

Returns the HTTP transport factory used.

Returns
Type Description
HttpTransportFactory

The HTTP transport factory.

getRefreshToken()

public String getRefreshToken()

Returns the refresh token obtained from the token exchange, if available.

Returns
Type Description
String

The refresh token, or null if not granted.

getTokenServerUri()

public URI getTokenServerUri()

Returns the URI of the token server used.

Returns
Type Description
URI

The token server URI.