GoogleSignInOptions.Builder

class GoogleSignInOptions.Builder


Builder for GoogleSignInOptions.

Summary

Public constructors

Default Builder for GoogleSignInOptions which starts with clean configuration.

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 functions

GoogleSignInOptions.Builder!

Specifies additional sign-in options via the given extension.

GoogleSignInOptions!

Builds the GoogleSignInOptions object.

GoogleSignInOptions.Builder!

Specifies that email info is requested by your application.

GoogleSignInOptions.Builder!

Specifies that user ID is requested by your application.

GoogleSignInOptions.Builder!

Specifies that an ID token for authenticated users is requested.

GoogleSignInOptions.Builder!

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

GoogleSignInOptions.Builder!

Specifies OAuth 2.0 scopes your application requests.

GoogleSignInOptions.Builder!

Specifies that offline access is requested.

GoogleSignInOptions.Builder!
@CanIgnoreReturnValue
requestServerAuthCode(
    serverClientId: String!,
    forceCodeForRefreshToken: Boolean
)

Specifies that offline access is requested.

GoogleSignInOptions.Builder!

Specifies an account name on the device that should be used.

GoogleSignInOptions.Builder!

Specifies a hosted domain restriction.

Public constructors

Builder

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),

Builder

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 functions

addExtension

@CanIgnoreReturnValue
fun addExtension(extension: GoogleSignInOptionsExtension!): GoogleSignInOptions.Builder!

Specifies additional sign-in options via the given extension.

Parameters
extension: GoogleSignInOptionsExtension!

A sign-in extension used to further configure API specific sign-in options. Supported values include: com.google.android.gms.games.Games.GamesOptions.

build

fun build(): GoogleSignInOptions!

Builds the GoogleSignInOptions object.

requestEmail

@CanIgnoreReturnValue
fun requestEmail(): GoogleSignInOptions.Builder!

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.

requestId

@CanIgnoreReturnValue
fun requestId(): GoogleSignInOptions.Builder!

Specifies that user ID is requested by your application.

requestIdToken

@CanIgnoreReturnValue
fun requestIdToken(serverClientId: String!): GoogleSignInOptions.Builder!

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

Parameters
serverClientId: String!

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

requestProfile

@CanIgnoreReturnValue
fun requestProfile(): GoogleSignInOptions.Builder!

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

requestScopes

@CanIgnoreReturnValue
fun requestScopes(scope: Scope!, scopes: Array<Scope!>!): GoogleSignInOptions.Builder!

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

Parameters
scope: Scope!

An OAuth 2.0 scope requested by your app.

scopes: Array<Scope!>!

More OAuth 2.0 scopes requested by your app.

requestServerAuthCode

@CanIgnoreReturnValue
fun requestServerAuthCode(serverClientId: String!): GoogleSignInOptions.Builder!

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

You don't need to use requestIdToken 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: String!

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

requestServerAuthCode

@CanIgnoreReturnValue
fun requestServerAuthCode(
    serverClientId: String!,
    forceCodeForRefreshToken: Boolean
): GoogleSignInOptions.Builder!

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

You don't need to use requestIdToken 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: String!

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

forceCodeForRefreshToken: Boolean

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.

setAccountName

@CanIgnoreReturnValue
fun setAccountName(accountName: String!): GoogleSignInOptions.Builder!

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: String!

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

setHostedDomain

@CanIgnoreReturnValue
fun setHostedDomain(hostedDomain: String!): GoogleSignInOptions.Builder!

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

Parameters
hostedDomain: String!

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