Skip to content

Commit

Permalink
docs: migration table (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
vonovak authored Feb 15, 2025
1 parent 1b1f232 commit eda0559
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Available on the public npm registry, this version:
- Uses functional, but deprecated [legacy Android Google Sign-In](https://web.archive.org/web/20240308064911/https://developers.google.com/identity/sign-in/android/start-integrating).
- Contains none of the extra features listed above.

> If you want to migrate from the public version to the Universal version, follow the [migration guide](migrating#migrating-from-original-to-universal-sign-in).
## Obtaining Universal Sign In {#obtaining-access}

Universal sign in requires [purchasing a license](https://universal-sign-in.com/#pricing), after which you will be able to configure your (or your colleagues') access to the private npm package and to the private repo with the sources and examples. Alternatively, as an Expo customer, obtain access through this [form](https://forms.gle/tpP7TfUGW1CwgaEZ8).
Expand Down Expand Up @@ -106,7 +108,7 @@ If you use another package manager ([such as Bun](https://bun.sh/docs/install/re

</Tabs>

If you're using the Universal version, open the lockfile (`yarn.lock` / `package-lock.json`...) and verify that the package is fetched from the GitHub registry (the entry must point to `npm.pkg.github.com`, not `registry.npmjs.org`). If it does not, it means that your package manager is not configured correctly - try uninstalling and reinstalling the package.
After installing: if you're using the Universal version, open the lockfile (`yarn.lock` / `package-lock.json`...) and verify that the package is fetched from the GitHub registry (the entry must point to `npm.pkg.github.com`, not `registry.npmjs.org`). If it does not, it means that your package manager is not configured correctly - try uninstalling and reinstalling the package.

There are several guides to follow now:

Expand Down
33 changes: 28 additions & 5 deletions docs/migrating.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
---
sidebar_position: 90
sidebar_label: Migrating
sidebar_position: 43
---

# Migrating to new JS API
# 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

Migrating from Original to Universal module is mostly about changing the method names: the table summarizes the mapping from Original module's calls to the Universal (OneTap) module's calls:

| Original Method | Universal (OneTap) Method | Notes |
| ------------------------ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `configure` | `configure` | Same functionality. |
| `signInSilently` | `signIn` | Universal's `signIn` attempts sign in without user interaction. |
| `signIn` | `createAccount` | Universal's `createAccount` is for first-time sign in (but can be used for existing users too). |
| `addScopes` | `requestAuthorization` | Similar functionality, different parameters. On Android, you can call `requestAuthorization` without being signed in! |
| `hasPlayServices` | `checkPlayServices` | Same functionality, different name. |
| `getCurrentUser` | Use `signIn` response | Manage the current user state yourself, or through libraries like [Firebase Auth](https://rnfirebase.io/auth/usage#listening-to-authentication-state) or [Supabase Auth](https://supabase.com/docs/reference/javascript/auth-onauthstatechange). |
| `getTokens` | Use `signIn` or `requestAuthorization` | Tokens are included in the response object. |
| `signOut` | `signOut` | Universal requires email/id parameter on web. |
| `revokeAccess` | Not yet provided by Google. | See [here](https://stackoverflow.com/a/78877334/2070942). |
| `hasPreviousSignIn` | Use `signIn` response | Check for `noSavedCredentialFound` response type. |
| `clearCachedAccessToken` | Not provided, presumably not needed. | - |

---

## Migrating to 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](https://github.com/react-native-google-signin/google-signin/pull/1326)). If you're upgrading from version 12 or earlier, you'll need to make some minor adjustments.

## Universal Sign In
### Universal Sign In

1. Add the [`configure`](one-tap#configure) method to your code. This method is required to be called to configure the module.

Expand Down Expand Up @@ -66,7 +89,7 @@ await GoogleOneTapSignIn.requestAuthorization({
});
```

## Original Sign In
### 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`](api#nosavedcredentialfound) object:
Expand Down
6 changes: 6 additions & 0 deletions docs/original.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ sidebar_position: 40

# Original Google sign in

:::tip

To migrate to Universal sign in, follow [this guide](migrating#migrating-from-original-to-universal-sign-in).

:::

This module exposes

- [Legacy Google Sign-In for Android](https://web.archive.org/web/20240308064911/https://developers.google.com/identity/sign-in/android/start-integrating). The underlying SDK is deprecated but functional.
Expand Down

0 comments on commit eda0559

Please sign in to comment.