AuthorizationRequest.Builder

public static final class AuthorizationRequest.Builder extends Object

Builder for AuthorizationRequest.

Public Constructor Summary

Public Method Summary

AuthorizationRequest
AuthorizationRequest.Builder
filterByHostedDomain(String hostedDomain)
Specifies a hosted domain restriction.
AuthorizationRequest.Builder
requestOfflineAccess(String serverClientId)
Specifies that offline access is requested.
AuthorizationRequest.Builder
requestOfflineAccess(String serverClientId, boolean forceCodeForRefreshToken)
Specifies that offline access is requested.
AuthorizationRequest.Builder
setAccount(Account account)
Specifies an account on the device that should be used.
AuthorizationRequest.Builder
setRequestedScopes(List<Scope> requestedScopes)
Sets the list of OAuth 2.0 scopes that the application is requesting.

Inherited Method Summary

Public Constructors

public Builder ()

Public Methods

public AuthorizationRequest build ()

public AuthorizationRequest.Builder filterByHostedDomain (String hostedDomain)

Specifies a hosted domain restriction.

By setting this, authorization will be restricted to accounts of the user in the specified domain.

Parameters
hostedDomain domain of the user to restrict (for example, "mycollege.edu"),

public AuthorizationRequest.Builder requestOfflineAccess (String serverClientId)

Specifies that offline access is requested. When offline access is requested, an authorization code is returned so the server can use the authorization code to exchange for a refresh token. The refresh token allows the server to access Google data when the user is not actively using the app.

Parameters
serverClientId The client ID of the server that will need the authorization code.

public AuthorizationRequest.Builder requestOfflineAccess (String serverClientId, boolean forceCodeForRefreshToken)

Specifies that offline access is requested. When offline access is requested, an authorization code is returned so the server can use the authorization code to exchange for a refresh token. The refresh token allows the server to access Google data when the user is not actively using the app.

Parameters
serverClientId The client ID of the server that will need the authorization code.
forceCodeForRefreshToken If true, the granted code can be exchanged for an access token and a refresh token. The first time you retrieve a code, a refresh token will be granted automatically. Subsequent requests will require additional user consent. Use false by default; only use true if your server has suffered some failure and lost the user's refresh token.

public AuthorizationRequest.Builder setAccount (Account account)

Specifies an account on the device that should be used.

Parameters
account The account on the device that should be used for authorization.

public AuthorizationRequest.Builder setRequestedScopes (List<Scope> requestedScopes)

Sets the list of OAuth 2.0 scopes that the application is requesting.