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.URI
callbackUri
private UserAuthorizer.ClientAuthenticationType
clientAuthenticationType
private ClientId
clientId
private PKCEProvider
pkce
private java.util.Collection<java.lang.String>
scopes
private java.net.URI
tokenServerUri
private TokenStore
tokenStore
private HttpTransportFactory
transportFactory
private java.net.URI
userAuthUri
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder()
protected
Builder(UserAuthorizer authorizer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UserAuthorizer
build()
java.net.URI
getCallbackUri()
UserAuthorizer.ClientAuthenticationType
getClientAuthenticationType()
ClientId
getClientId()
HttpTransportFactory
getHttpTransportFactory()
PKCEProvider
getPKCEProvider()
java.util.Collection<java.lang.String>
getScopes()
java.net.URI
getTokenServerUri()
TokenStore
getTokenStore()
java.net.URI
getUserAuthUri()
UserAuthorizer.Builder
setCallbackUri(java.net.URI callbackUri)
Sets the redirect URI registered with your OAuth provider.UserAuthorizer.Builder
setClientAuthenticationType(UserAuthorizer.ClientAuthenticationType clientAuthentication)
Sets the optionalUserAuthorizer.ClientAuthenticationType
, one of the client authentication methods defined in RFC 7591.UserAuthorizer.Builder
setClientId(ClientId clientId)
Sets the OAuth 2.0 client ID.UserAuthorizer.Builder
setHttpTransportFactory(HttpTransportFactory transportFactory)
Sets the HTTP transport factory.UserAuthorizer.Builder
setPKCEProvider(PKCEProvider pkce)
Sets the optionalPKCEProvider
to enable Proof Key for Code Exchange to be used.UserAuthorizer.Builder
setScopes(java.util.Collection<java.lang.String> scopes)
Sets the OAuth 2.0 scopes to request.UserAuthorizer.Builder
setTokenServerUri(java.net.URI tokenServerUri)
Sets the token exchange endpoint.UserAuthorizer.Builder
setTokenStore(TokenStore tokenStore)
Sets theTokenStore
to use for long term token storage.UserAuthorizer.Builder
setUserAuthUri(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
Builder
object
-
setTokenStore
@CanIgnoreReturnValue public UserAuthorizer.Builder setTokenStore(TokenStore tokenStore)
Sets theTokenStore
to use for long term token storage.- Parameters:
tokenStore
- the token store- Returns:
- this
Builder
object
-
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
Builder
object
-
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
Builder
object
-
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
Builder
object
-
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
Builder
object
-
setHttpTransportFactory
@CanIgnoreReturnValue public UserAuthorizer.Builder setHttpTransportFactory(HttpTransportFactory transportFactory)
Sets the HTTP transport factory.- Parameters:
transportFactory
- theHttpTransportFactory
to set- Returns:
- this
Builder
object
-
setPKCEProvider
@CanIgnoreReturnValue public UserAuthorizer.Builder setPKCEProvider(PKCEProvider pkce)
Sets the optionalPKCEProvider
to 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
- thePKCEProvider
to set- Returns:
- this
Builder
object
-
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
- theClientAuthenticationType
to set- Returns:
- this
Builder
object
-
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()
-
-