From 6a09a76eec76cebc7ed75d7e64857c36aab112fd Mon Sep 17 00:00:00 2001 From: dshukertjr <18113850+dshukertjr@users.noreply.github.com> Date: Fri, 15 Sep 2023 16:30:04 +0900 Subject: [PATCH] fix: update flutter code on apple auth docs to use the latest features --- .../guides/auth/social-login/auth-apple.mdx | 32 +++---------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/apps/docs/pages/guides/auth/social-login/auth-apple.mdx b/apps/docs/pages/guides/auth/social-login/auth-apple.mdx index ca8adae7b3b..e12a868d341 100644 --- a/apps/docs/pages/guides/auth/social-login/auth-apple.mdx +++ b/apps/docs/pages/guides/auth/social-login/auth-apple.mdx @@ -64,37 +64,13 @@ Unlike the OAuth flow which requires the use of a web browser, the native Sign i When the user provides consent, Apple issues an identity token (commonly abbreviated as ID token) that is then sent to your project's Supabase Auth server. When valid, a new user session is started by issuing an access and refresh token from Supabase Auth. -If you are building an iOS or macOS app using Flutter, you can use [apple_sign_in](https://pub.dev/packages/sign_in_with_apple) package to quickly get the user's consent and sign them in to your Supabase project: +If you are building an iOS or macOS app using Flutter, you can use the [signInWithApple()](https://supabase.com/docs/reference/dart/sign-in-with-apple) method to perform Apple sign in: ```dart -import 'package:sign_in_with_apple/sign_in_with_apple.dart'; -import 'package:crypto/crypto.dart'; +import 'package:supabase_flutter/supabase_flutter.dart'; -Future signInWithApple() { - - // Generate a random string - final rawNonce = _generateRandomString(); - final hashedNonce = sha256.convert(utf8.encode(rawNonce)).toString(); - - final credential = await SignInWithApple.getAppleIDCredential( - scopes: [ - AppleIDAuthorizationScopes.email, - AppleIDAuthorizationScopes.fullName, - ], - nonce: hashedNonce, - ); - - final idToken = credential.identityToken; - if (idToken == null) { - throw 'Could not find ID Token from generated credential.'; - } - - return signInWithIdToken( - provider: Provider.apple, - idToken: idToken, - nonce: rawNonce, - ); -} +final AuthResponse res = await supabase.auth.signInWithApple(); +final User? user = res.user; ``` In the Supabase JavaScript library, which you can use with web-based native frameworks like React Native or Expo, you can invoke this functionality like so: