GetGoogleIdOption.Builder

public final class GetGoogleIdOption.Builder


A Builder for GetGoogleIdOption.

Summary

Public constructors

Public methods

final @NonNull GetGoogleIdOption.Builder
associateLinkedAccounts(
    @NonNull String linkedServiceId,
    List<@NonNull String> idTokenDepositionScopes
)

Sets whether to support sign-in using Google accounts that are linked to your users' accounts.

final @NonNull GetGoogleIdOption
final @NonNull GetGoogleIdOption.Builder
setAutoSelectEnabled(boolean autoSelectEnabled)

Sets the auto-select behavior in the request.

final @NonNull GetGoogleIdOption.Builder
setFilterByAuthorizedAccounts(boolean filterByAuthorizedAccounts)

Sets whether to only allow the user to select from Google accounts that are already authorized to sign in to your application.

final @NonNull GetGoogleIdOption.Builder

Sets the nonce to use when generating a Google ID token.

final @NonNull GetGoogleIdOption.Builder
setRequestVerifiedPhoneNumber(boolean requestVerifiedPhoneNumber)

Sets whether to request for a verified phone number during sign-ups.

final @NonNull GetGoogleIdOption.Builder
setServerClientId(@NonNull String serverClientId)

Sets the server's client ID to use as the audience for Google ID tokens generated during the sign-in.

Public constructors

Builder

public Builder()

Public methods

associateLinkedAccounts

public final @NonNull GetGoogleIdOption.Builder associateLinkedAccounts(
    @NonNull String linkedServiceId,
    List<@NonNull String> idTokenDepositionScopes
)

Sets whether to support sign-in using Google accounts that are linked to your users' accounts.

When such a credential is selected, a Google ID token for the Google account that the selected account is linked to, will first be deposited to your server and then returned to you. Similar to the regular sign-in, your backend could use the ID token to sign the user in. Note that, the ID token deposition will only happen the first time signing in, using this credential. Subsequent sign-ins will not require a deposition, since the ID token will already have been associated with your user's account.

Parameters
@NonNull String linkedServiceId

service ID used when linking accounts to a Google account.

List<@NonNull String> idTokenDepositionScopes

Oauth scopes that Google will need to deposit a Google ID token to your application's backend server. This is optional and can be set to null. Only required if Google requires particular scopes to be able to deposit the ID token.

build

public final @NonNull GetGoogleIdOption build()

setAutoSelectEnabled

public final @NonNull GetGoogleIdOption.Builder setAutoSelectEnabled(boolean autoSelectEnabled)

Sets the auto-select behavior in the request.

For users who opt-in, Auto Select allows a credential to be selected automatically without waiting for a user action (such as tapping on the "continue" button). A credential can be auto selected if 1) only one credential can be used for sign-in; and 2) no further actions need to be taken for this credential (for example, data sharing permissions are already collected for a Google account).

setFilterByAuthorizedAccounts

public final @NonNull GetGoogleIdOption.Builder setFilterByAuthorizedAccounts(boolean filterByAuthorizedAccounts)

Sets whether to only allow the user to select from Google accounts that are already authorized to sign in to your application. The default value is true.

If {@code true}, the user will not be able to select any Google account that would otherwise require explicit authorization to share basic profile/email data with your application. This may reduce some friction in the sign-in user journey, and guarantees that the returned credential is for a "returning user", but limits the user's freedom to choose among all the Google accounts on the device.

Parameters
boolean filterByAuthorizedAccounts

whether to only allow the user to select from Google accounts that are already authorized to sign in to your application

setNonce

public final @NonNull GetGoogleIdOption.Builder setNonce(String nonce)

Sets the nonce to use when generating a Google ID token.

Parameters
String nonce

the nonce to use during ID token generation

setRequestVerifiedPhoneNumber

public final @NonNull GetGoogleIdOption.Builder setRequestVerifiedPhoneNumber(boolean requestVerifiedPhoneNumber)

Sets whether to request for a verified phone number during sign-ups.

In order to use this feature, the [filterByAuthorizedAccounts] field must be explicitly set to false, because this feature is only available during sign-ups.

setServerClientId

public final @NonNull GetGoogleIdOption.Builder setServerClientId(@NonNull String serverClientId)

Sets the server's client ID to use as the audience for Google ID tokens generated during the sign-in.

Parameters
@NonNull String serverClientId

the client ID of the server to which the ID token will be issued