Skip to content

Add Apple SignIn support#59

Closed
JekaNS wants to merge 8 commits intoinvertase:mainfrom
JekaNS:main
Closed

Add Apple SignIn support#59
JekaNS wants to merge 8 commits intoinvertase:mainfrom
JekaNS:main

Conversation

@JekaNS
Copy link
Copy Markdown

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

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 18, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ JekaNS
❌ i-kovtun-veeam
You have signed the CLA already but the status is still pending? Let us recheck it.

@JekaNS JekaNS closed this Aug 18, 2024
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.

3 participants