Package com.google.auth.oauth2
Class UserAuthorizer.Builder
- java.lang.Object
-
- com.google.auth.oauth2.UserAuthorizer.Builder
-
- Enclosing class:
- UserAuthorizer
public static class UserAuthorizer.Builder extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.URIcallbackUriprivate UserAuthorizer.ClientAuthenticationTypeclientAuthenticationTypeprivate ClientIdclientIdprivate PKCEProviderpkceprivate java.util.Collection<java.lang.String>scopesprivate java.net.URItokenServerUriprivate TokenStoretokenStoreprivate HttpTransportFactorytransportFactoryprivate java.net.URIuserAuthUri
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder()protectedBuilder(UserAuthorizer authorizer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UserAuthorizerbuild()java.net.URIgetCallbackUri()UserAuthorizer.ClientAuthenticationTypegetClientAuthenticationType()ClientIdgetClientId()HttpTransportFactorygetHttpTransportFactory()PKCEProvidergetPKCEProvider()java.util.Collection<java.lang.String>getScopes()java.net.URIgetTokenServerUri()TokenStoregetTokenStore()java.net.URIgetUserAuthUri()UserAuthorizer.BuildersetCallbackUri(java.net.URI callbackUri)Sets the redirect URI registered with your OAuth provider.UserAuthorizer.BuildersetClientAuthenticationType(UserAuthorizer.ClientAuthenticationType clientAuthentication)Sets the optionalUserAuthorizer.ClientAuthenticationType, one of the client authentication methods defined in RFC 7591.UserAuthorizer.BuildersetClientId(ClientId clientId)Sets the OAuth 2.0 client ID.UserAuthorizer.BuildersetHttpTransportFactory(HttpTransportFactory transportFactory)Sets the HTTP transport factory.UserAuthorizer.BuildersetPKCEProvider(PKCEProvider pkce)Sets the optionalPKCEProviderto enable Proof Key for Code Exchange to be used.UserAuthorizer.BuildersetScopes(java.util.Collection<java.lang.String> scopes)Sets the OAuth 2.0 scopes to request.UserAuthorizer.BuildersetTokenServerUri(java.net.URI tokenServerUri)Sets the token exchange endpoint.UserAuthorizer.BuildersetTokenStore(TokenStore tokenStore)Sets theTokenStoreto use for long term token storage.UserAuthorizer.BuildersetUserAuthUri(java.net.URI userAuthUri)Sets the authorization URI where the user is directed to log in and grant authorization.
-
-
-
Field Detail
-
clientId
private ClientId clientId
-
tokenStore
private TokenStore tokenStore
-
callbackUri
private java.net.URI callbackUri
-
tokenServerUri
private java.net.URI tokenServerUri
-
userAuthUri
private java.net.URI userAuthUri
-
scopes
private java.util.Collection<java.lang.String> scopes
-
transportFactory
private HttpTransportFactory transportFactory
-
pkce
private PKCEProvider pkce
-
clientAuthenticationType
private UserAuthorizer.ClientAuthenticationType clientAuthenticationType
-
-
Constructor Detail
-
Builder
protected Builder()
-
Builder
protected Builder(UserAuthorizer authorizer)
-
-
Method Detail
-
setClientId
@CanIgnoreReturnValue public UserAuthorizer.Builder setClientId(ClientId clientId)
Sets the OAuth 2.0 client ID.- Parameters:
clientId- the client ID- Returns:
- this
Builderobject
-
setTokenStore
@CanIgnoreReturnValue public UserAuthorizer.Builder setTokenStore(TokenStore tokenStore)
Sets theTokenStoreto use for long term token storage.- Parameters:
tokenStore- the token store- Returns:
- this
Builderobject
-
setScopes
@CanIgnoreReturnValue public UserAuthorizer.Builder setScopes(java.util.Collection<java.lang.String> scopes)
Sets the OAuth 2.0 scopes to request.- Parameters:
scopes- the scopes to request- Returns:
- this
Builderobject
-
setTokenServerUri
@CanIgnoreReturnValue public UserAuthorizer.Builder setTokenServerUri(java.net.URI tokenServerUri)
Sets the token exchange endpoint.- Parameters:
tokenServerUri- the token exchange endpoint to use- Returns:
- this
Builderobject
-
setCallbackUri
@CanIgnoreReturnValue public UserAuthorizer.Builder setCallbackUri(java.net.URI callbackUri)
Sets the redirect URI registered with your OAuth provider. This is where the user's browser will be redirected after granting or denying authorization.- Parameters:
callbackUri- the redirect URI- Returns:
- this
Builderobject
-
setUserAuthUri
@CanIgnoreReturnValue public UserAuthorizer.Builder setUserAuthUri(java.net.URI userAuthUri)
Sets the authorization URI where the user is directed to log in and grant authorization.- Parameters:
userAuthUri- the authorization URI- Returns:
- this
Builderobject
-
setHttpTransportFactory
@CanIgnoreReturnValue public UserAuthorizer.Builder setHttpTransportFactory(HttpTransportFactory transportFactory)
Sets the HTTP transport factory.- Parameters:
transportFactory- theHttpTransportFactoryto set- Returns:
- this
Builderobject
-
setPKCEProvider
@CanIgnoreReturnValue public UserAuthorizer.Builder setPKCEProvider(PKCEProvider pkce)
Sets the optionalPKCEProviderto enable Proof Key for Code Exchange to be used. This enhances security by using a code challenge and verifier to prevent authorization code interception attacks.- Parameters:
pkce- thePKCEProviderto set- Returns:
- this
Builderobject
-
setClientAuthenticationType
@CanIgnoreReturnValue public UserAuthorizer.Builder setClientAuthenticationType(UserAuthorizer.ClientAuthenticationType clientAuthentication)
Sets the optionalUserAuthorizer.ClientAuthenticationType, one of the client authentication methods defined in RFC 7591. This specifies how your application authenticates itself to the authorization server.- Parameters:
clientAuthentication- theClientAuthenticationTypeto set- Returns:
- this
Builderobject
-
getClientId
public ClientId getClientId()
-
getTokenStore
public TokenStore getTokenStore()
-
getScopes
public java.util.Collection<java.lang.String> getScopes()
-
getTokenServerUri
public java.net.URI getTokenServerUri()
-
getCallbackUri
public java.net.URI getCallbackUri()
-
getUserAuthUri
public java.net.URI getUserAuthUri()
-
getHttpTransportFactory
public HttpTransportFactory getHttpTransportFactory()
-
getPKCEProvider
public PKCEProvider getPKCEProvider()
-
getClientAuthenticationType
public UserAuthorizer.ClientAuthenticationType getClientAuthenticationType()
-
build
public UserAuthorizer build()
-
-