Skip to content

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