Package com.google.auth.oauth2
Class UserAuthorizer.TokenResponseWithConfig
java.lang.Object
com.google.auth.oauth2.UserAuthorizer.TokenResponseWithConfig
- Enclosing class:
- UserAuthorizer
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();
-
Method Summary
Modifier and TypeMethodDescriptionReturns the access token obtained from the token exchange.Returns the OAuth 2.0 client ID used.Returns the OAuth 2.0 client secret used.Returns the HTTP transport factory used.@Nullable StringReturns the refresh token obtained from the token exchange, if available.Returns the URI of the token server used.
-
Method Details
-
getClientId
Returns the OAuth 2.0 client ID used.- Returns:
- The client ID.
-
getClientSecret
Returns the OAuth 2.0 client secret used.- Returns:
- The client secret.
-
getAccessToken
Returns the access token obtained from the token exchange.- Returns:
- The access token.
-
getHttpTransportFactory
Returns the HTTP transport factory used.- Returns:
- The HTTP transport factory.
-
getTokenServerUri
Returns the URI of the token server used.- Returns:
- The token server URI.
-
getRefreshToken
Returns the refresh token obtained from the token exchange, if available.- Returns:
- The refresh token, or null if not granted.
-