Summary: Ctors | Methods | Inherited Methods | [Expand All]
public static final class

# GoogleSignInOptions.Builder

extends Object

java.lang.Object
↳ | com.google.android.gms.auth.api.signin.GoogleSignInOptions.Builder

## Class Overview

Builder for `GoogleSignInOptions`,

## Summary

Public Constructors
| GoogleSignInOptions.Builder() Default Builder for `GoogleSignInOptions` which starts with clean configuration.
| GoogleSignInOptions.Builder(GoogleSignInOptions googleSignInOptions) A Builder for `GoogleSignInOptions` which you can specify one of the default configurations Google (will) provide and make additional configurations based on it.

Public Methods
GoogleSignInOptions | build() Builds the `GoogleSignInOptions` object.
GoogleSignInOptions.Builder | requestEmail() Specifies that email info is requested by your application.
GoogleSignInOptions.Builder | requestId() Specifies that user ID is requested by your application.
GoogleSignInOptions.Builder | requestIdToken(String serverClientId) Specifies that an ID token for authenticated users is requested.
GoogleSignInOptions.Builder | requestProfile() Specifies that user's profile info is requested by your application.
GoogleSignInOptions.Builder | requestScopes(Scope scope, Scope... scopes) Specifies OAuth 2.0 scopes your application requests.
GoogleSignInOptions.Builder | requestServerAuthCode(String serverClientId) Specifies that offline access is requested.
GoogleSignInOptions.Builder | requestServerAuthCode(String serverClientId, boolean forceCodeForRefreshToken) Specifies that offline access is requested.
GoogleSignInOptions.Builder | setAccountName(String accountName) Specifies an account name on the device that should be used.
GoogleSignInOptions.Builder | setHostedDomain(String hostedDomain) Specifies a hosted domain restriction.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Constructors

#### public GoogleSignInOptions.Builder ()

Default Builder for `GoogleSignInOptions` which starts with clean configuration.

If you are trying to implement Sign In, i.e. you want to get back user identity, you can start with `new GoogleSignInOptions(GoogleSignInOptions.DEFAULT_SIGN_IN)`,

#### public GoogleSignInOptions.Builder (GoogleSignInOptions googleSignInOptions)

A Builder for `GoogleSignInOptions` which you can specify one of the default configurations Google (will) provide and make additional configurations based on it. e.g.`DEFAULT_SIGN_IN`.

## Public Methods

#### public GoogleSignInOptions build ()

Builds the `GoogleSignInOptions` object.

##### Returns

- a `GoogleSignInOptions` instance.

#### public GoogleSignInOptions.Builder requestEmail ()

Specifies that email info is requested by your application. Note that we don't recommend keying user by email address since email address might change. Keying user by ID is the preferable approach.

#### public GoogleSignInOptions.Builder requestId ()

Specifies that user ID is requested by your application.

#### public GoogleSignInOptions.Builder requestIdToken (String serverClientId)

Specifies that an ID token for authenticated users is requested. Requesting an ID token requires that the server client ID be specified.

##### Parameters

serverClientId | The client ID of the server that will verify the integrity of the token.

#### public GoogleSignInOptions.Builder requestProfile ()

Specifies that user's profile info is requested by your application.

#### public GoogleSignInOptions.Builder requestScopes (Scope scope, Scope... scopes)

Specifies OAuth 2.0 scopes your application requests. See `Scopes` for more information.

##### Parameters

scope | An OAuth 2.0 scope requested by your app.
scopes | More OAuth 2.0 scopes requested by your app.

#### public GoogleSignInOptions.Builder requestServerAuthCode (String serverClientId)

Specifies that offline access is requested. Requesting offline access requires that the server client ID be specified.

You don't need to use `requestIdToken(String)` when you use this option. When your server exchanges the code for tokens, an ID token will be returned together (as long as you either use `requestEmail()` or `requestProfile()` along with your configuration).

The first time you retrieve a code, a refresh_token will be granted automatically. Subsequent requests will only return codes that can be exchanged for access token.

##### Parameters

serverClientId | The client ID of the server that will need the auth code.

#### public GoogleSignInOptions.Builder requestServerAuthCode (String serverClientId, boolean forceCodeForRefreshToken)

Specifies that offline access is requested. Requesting offline access requires that the server client ID be specified.

You don't need to use `requestIdToken(String)` when you use this option. When your server exchanges the code for tokens, an ID token will be returned together (as long as you either use `requestEmail()` or `requestProfile()` along with this configuration).

##### Parameters

serverClientId | The client ID of the server that will need the auth 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 GoogleSignInOptions.Builder setAccountName (String accountName)

Specifies an account name on the device that should be used. If this is never called, the client will use the current default account for this application.

##### Parameters

accountName | The account name on the device that should be used to sign in.

#### public GoogleSignInOptions.Builder setHostedDomain (String hostedDomain)

Specifies a hosted domain restriction. By setting this, sign in will be restricted to accounts of the user in the specified domain.

##### Parameters

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