Skip to main content

Migration guides

There are 2 migrations described here: from Original to Universal Sign In and from the old JS API to the new JS API.

Migrating from Original to Universal Sign In

For authentication, prefer authenticate. It checks prerequisites, tries to restore a saved credential, starts account creation if needed, and falls back to explicit sign-in when the user still needs to pick or add an account. It returns user, error, or isCancelled. The table also lists advanced method mappings for apps that need to control each step themselves:

Original MethodUniversal (OneTap) MethodNotes
configureconfigureSame functionality.
signInSilently/signInauthenticateRecommended for the complete authentication flow.
signInSilentlysignInAdvanced method. Universal's signIn attempts sign in without user interaction.
signIncreateAccount/presentExplicitSignInAdvanced methods for apps that need to control the interactive steps directly.
addScopesrequestAuthorizationSimilar functionality, different parameters. On Android, you can call requestAuthorization without being signed in!
hasPlayServicescheckPlayServicesSame functionality, different name.
getCurrentUserUse authenticate responseManage the current user state yourself, or through libraries like Firebase Auth or Supabase Auth.
getTokensUse authenticate or requestAuthorizationTokens are included in the response object.
signOutsignOut
revokeAccessrevokeAccessUniversal requires email/id parameter on web.
hasPreviousSignInUsually not neededUse authenticate to authenticate. If you specifically need to know whether a saved credential exists, call the advanced signIn method and check for noSavedCredentialFound.
clearCachedAccessTokenclearCachedAccessTokenSame functionality.

Migrating to the new JS API

Version 13 introduced a new JS API, which changes some method response signatures and makes minor changes to error handling (details here). If you're upgrading from version 12 or earlier, you'll need to make some minor adjustments.

Universal Sign In

  1. Add the configure method to your code. This method is required to be called to configure the module.

  2. Prefer authenticate for authentication. It returns user, error, or isCancelled:

const signIn = async () => {
- const userInfo = await GoogleOneTapSignIn.signIn({
- webClientId: `autoDetect`, // works only if you use Firebase
- iosClientId: config.iosClientId, // only needed if you're not using Firebase
- });
- setState({ userInfo }); // use e.g. `userInfo.name`
+ const { user, error, isCancelled } = await GoogleOneTapSignIn.authenticate();
+
+ if (user) {
+ setState({ userInfo: user });
+ } else if (isCancelled) {
+ // sign in was cancelled
+ } else if (error) {
+ switch (error.code) {
+ case statusCodes.PLAY_SERVICES_NOT_AVAILABLE:
+ // Android-only: play services not available or outdated
+ // Web: the Google Client Library is not loaded yet
+ break;
+ default:
+ // something else happened
+ }
+ }
};
  1. If requesting offline access in requestAuthorization on Android, add enabled: true:
await GoogleOneTapSignIn.requestAuthorization({
offlineAccess: {
+ enabled: true,
},
});

Original Sign In

  1. Follow step 2. from above for signIn, addScopes and signInSilently methods.
  2. remove SIGN_IN_REQUIRED mentions. This case is now handled with NoSavedCredentialFound object:
const getCurrentUserInfo = async () => {
try {
const response = await GoogleSignin.signInSilently();
+ if (isSuccessResponse(response)) {
+ setState({ userInfo: response.data })
+ } else if (isNoSavedCredentialFoundResponse(response)) {
+ // user has not signed in yet
+ }
- setState({ userInfo: response });
} catch (error) {
- if (error.code === statusCodes.SIGN_IN_REQUIRED) {
- // user has not signed in yet
- } else {
- // some other error
- }
}
};