We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Show ASAuthorizationController with a simple nonce. Once we have the idToken, create an OAuthProvider.appleCredential and pass to Firebase Auth
ASAuthorizationController
idToken
OAuthProvider.appleCredential
Firebase Auth
final class AppleLoginService: NSObject { static let shared = AppleLoginService() private var nonce: String? func show() { let nonce = generateNonce() self.nonce = nonce let provider = ASAuthorizationAppleIDProvider() let request = provider.createRequest() request.requestedScopes = [.fullName, .email] request.nonce = nonce?.sha256 let vc = ASAuthorizationController(authorizationRequests: [request]) vc.delegate = self vc.presentationContextProvider = self vc.performRequests() } private func generateNonce() -> String? { "0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._" .shuffled() .description } } extension AppleLoginService: ASAuthorizationControllerDelegate { func authorizationController( controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization ) { guard let appleCredential = authorization.credential as? ASAuthorizationAppleIDCredential, let idTokenData = appleCredential.identityToken, let idToken = String(data: idTokenData, encoding: .utf8) else { return } let credential = OAuthProvider.appleCredential( withIDToken: idToken, rawNonce: nonce, fullName: appleCredential.fullName ) Task { do { let result = try await Auth.auth().signIn(with: credential) } catch { printD(error) } } } func authorizationController( controller: ASAuthorizationController, didCompleteWithError error: any Error ) { printD(error) } } extension AppleLoginService: ASAuthorizationControllerPresentationContextProviding { func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { UIApplication.shared.activeWindow! } }
If we're using Supabase, we can call signInWithIdToken with .apple provider
signInWithIdToken
.apple
supabase.auth.signInWithIdToken( credentials: .init( provider: .apple, idToken: idToken, nonce: nonce ) )
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Show
ASAuthorizationController
with a simple nonce. Once we have theidToken
, create anOAuthProvider.appleCredential
and pass toFirebase Auth
If we're using Supabase, we can call
signInWithIdToken
with.apple
providerRead more
The text was updated successfully, but these errors were encountered: