From af7d12cedb07a0346efb3b1a71c4eb4ba6851198 Mon Sep 17 00:00:00 2001 From: Tyler Date: Wed, 5 Feb 2025 10:16:15 +0900 Subject: [PATCH] docs: Add Flutter code sample for Firebase Auth integration guide (#31087) * docs: Add Flutter code sample for accessToken function * docs: fix the code sample --- .../guides/auth/third-party/firebase-auth.mdx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/docs/content/guides/auth/third-party/firebase-auth.mdx b/apps/docs/content/guides/auth/third-party/firebase-auth.mdx index 0bf453afd5d..92d89657837 100644 --- a/apps/docs/content/guides/auth/third-party/firebase-auth.mdx +++ b/apps/docs/content/guides/auth/third-party/firebase-auth.mdx @@ -36,6 +36,26 @@ Make sure the all users in your application have the `role: 'authenticated'` [cu + + +Creating a client for the Web is as easy as passing the `accessToken` async function. This function should [return the Firebase Auth JWT of the current user](https://firebase.google.com/docs/auth/admin/verify-id-tokens) (or null if no such user) is found. + +```dart +await Supabase.initialize( + url: supabaseUrl, + anonKey: supabaseKey, + debug: false, + accessToken: () async { + final token = await FirebaseAuth.instance.currentUser?.getIdToken(); + return token; + }, +); +``` + +Make sure the all users in your application have the `role: 'authenticated'` [custom claim](https://firebase.google.com/docs/auth/admin/custom-claims) set. If you're using the `onCreate` Cloud Function to add this custom claim to newly signed up users, you will need to call `getIdToken(/* forceRefresh */ true)` immediately after sign up as the `onCreate` function does not run synchronously. + + + ```swift