Skip to content

Add Apple signIn support#60

Open
JekaNS wants to merge 2 commits intoinvertase:mainfrom
JekaNS:main
Open

Add Apple signIn support#60
JekaNS wants to merge 2 commits intoinvertase:mainfrom
JekaNS:main

Conversation

@JekaNS
Copy link

@JekaNS JekaNS commented Aug 18, 2024

Added AppleSignInArgs.
After user authorized in WebView with AppleID, we can create OAuth credentials for Firebase using OAuthProvider("apple.com").credential(...)

Please pay attention that on windows platforms firebase_auth package was throw exception when trying use credentials with rawNonce.
It was fixed in firebase_auth: 5.1.4 PR#13086

Usage exmaple:

import 'package:desktop_webview_auth/desktop_webview_auth.dart';
import 'package:desktop_webview_auth/apple.dart';
import 'package:firebase_auth/firebase_auth.dart';  

final args = AppleSignInArgs(
    clientId: "your-service-id", //Services ID used as the web application identifier
    redirectUri: "https://your-project.firebaseapp.com/__/auth/handler",
);

try {
    final result = await DesktopWebviewAuth.signIn(args);
    if (result == null || result.idToken == null) {
      throw Exception("Authorize process terminated");
    }
} catch (err) {
    // something went wrong
}

final credential = OAuthProvider("apple.com").credential(
    idToken: result.idToken!,
    rawNonce: args.nonce,
);

FirebaseAuth.instance.signInWithCredential(credential);

@JekaNS
Copy link
Author

JekaNS commented Dec 26, 2025

Hi,
Any updates here? Can some one merge this PR?

Bug in firebase_auth about exception when pass credentials with rawNonce is fixed a year ago. firebase/flutterfire#13086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant