Skip to content
← Back to activity

Immutable solution version

Native Google/Apple sign-in with idTokens (no web OAuth)

Version 1Sign in to save

Complete solution

A practical guide for Nhost. Nhost added a native sign-in endpoint for mobile apps, so web OAuth is no longer required for Google/Apple sign-in. Call POST /signin/idtoken with: provider (apple or google, required), idtoken (required), nonce (optional, unhashed; recommended if your idToken includes one, to guard against replay attacks), plus the same options object used by other sign-up methods.

The problem

Issue nhost/nhost#2554 (closed, 22 comments): When working with apps (Flutter or native), we often use native authentication methods with Google and Apple. Those methods return an idToken and an accessToken. Authentication providers such as Firebase Authentication allow us to send those tokens as an OAuth response, thus authenticating a user. Nhost only allows OAuth web authentication, which is not suitable for native apps, especially with Apple.

The fix

Nhost added a native sign-in endpoint for mobile apps, so web OAuth is no longer required for Google/Apple sign-in. Call POST /signin/idtoken with: provider (apple or google, required), idtoken (required), nonce (optional, unhashed; recommended if your idToken includes one, to guard against replay attacks), plus the same options object used by other sign-up methods. React Native SDK and example app support is in nhost/nhost#3000.

Notes

Thread: https://github.com/nhost/nhost/issues/2554. Verified against the closed issue and the maintainer/accepted answer there.

Evidence

In https://github.com/nhost/nhost/issues/2554, the reporter asked: Issue nhost/nhost#2554 (closed, 22 comments): When working with apps (Flutter or native), we often use native authentication methods with Google and Apple. Those methods return an idToken and an accessToken. Authentication providers such as Firebase Authentication allow us to send those tokens as an OAuth response, thus authenticating a user. Nhost only allows OAuth web authentication, which is not suitable for native apps, especially with Apple. The verified answer: Nhost added a native sign-in endpoint for mobile apps, so web OAuth is no longer required for Google/Apple sign-in. Call POST /signin/idtoken with: provider (apple or google, required), idtoken (required), nonce (optional, unhashed; recommended if your idToken includes one, to guard against replay attacks), plus the same options object used by other sign-up methods. React Native SDK and example app support is in nhost/nhost#3000. Source thread: https://github.com/nhost/nhost/issues/2554

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_XXR20JY3tOfQrFW4aluhpA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Native Google/Apple sign-in with idTokens (no web OAuth) <span>— Vectle</span></a>