AI-generated Key Takeaways
-
AuthorizationRequest.Builderis used to buildAuthorizationRequestobjects. -
Key methods include adding resource parameters, filtering by hosted domain, requesting offline access, setting the account, specifying whether to opt-out of including granted scopes, and setting requested scopes.
-
The
build()method is used to finalize and create theAuthorizationRequest.
Builder for AuthorizationRequest.
Public Constructor Summary
|
Builder()
|
Public Method Summary
| AuthorizationRequest.Builder |
addResourceParameter(AuthorizationRequest.ResourceParameter
resourceParameter, String
resourceParameterValue)
Adds a resource parameter.
|
| AuthorizationRequest |
build()
Builds the
AuthorizationRequest.
|
| AuthorizationRequest.Builder | |
| AuthorizationRequest.Builder | |
| AuthorizationRequest.Builder |
requestOfflineAccess(String
serverClientId, boolean forceCodeForRefreshToken)
Specifies that offline access is requested.
|
| AuthorizationRequest.Builder | |
| AuthorizationRequest.Builder |
setOptOutIncludingGrantedScopes(boolean optOutIncludingGrantedScopes)
Specifies if previously granted scopes should be skipped.
|
| 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.Builder addResourceParameter (AuthorizationRequest.ResourceParameter resourceParameter, String resourceParameterValue)
Adds a resource parameter.
public AuthorizationRequest build ()
Builds the
AuthorizationRequest.
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 setOptOutIncludingGrantedScopes (boolean optOutIncludingGrantedScopes)
Specifies if previously granted scopes should be skipped. Default value is
false.
By default, previously granted scopes are included in the authorization response.
public AuthorizationRequest.Builder setRequestedScopes (List<Scope> requestedScopes)
Sets the list of OAuth 2.0 scopes that the application is requesting.