Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Apple signIn support #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add Apple signIn support #60

wants to merge 1 commit into from

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);

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