Back

Sign In with Apple integration

  • 0
  • Accounts
  • Apple
SaurabhJamadagni
17 Jun, 2023, 15:30

Hey all! I was trying to implement 'Sign in with Apple' in my native iOS app. Enabling Apple as an OAuth provider right now involves redirecting the user to a apple sign in page based on a Return URL. The SignInWithAppleButton available for SwiftUI takes in a request and returns an authentication result with the user credentials such as name and email and assigns a user ID. This method doesn't redirect the user outside the app. Instead, uses the user's Apple ID for details and biometrics or passkey for authentication in the app itself.

Is there a way to implement this button currently in auth so that it creates a new user in the Users table of the Appwrite project based on the result and credentials received?

TypeScript
SignInWithAppleButton(.signIn) { request in
    request.requestedScopes = [.email, .fullName]
} onCompletion: { result in
    switch result {
    case .success(let auth):
        switch auth.credential {
        case let authCredential as ASAuthorizationAppleIDCredential:
            // Crete a new user with the received credentials.
            
            let name = authCredential.fullName
        default:
            break
        }
    case .failure(let error):
        print(error.localizedDescription)
    }
}

Any ideas as to how I could make this work? Would love to contribute too if anything is in the works πŸ™‚

TL;DR
The user is trying to implement 'Sign in with Apple' in their iOS app using Appwrite. They are asking if it is possible to create a new user in the Appwrite project's Users table based on the result and credentials received from the Apple authentication. They provide sample code for the implementation. There is no solution provided in the thread.
Drake
17 Jun, 2023, 15:37

To use our oauth integration with apple, you'll have to authenticate via our flow.

You can πŸ‘ this related issue: https://github.com/appwrite/appwrite/issues/2611

SaurabhJamadagni
17 Jun, 2023, 17:39

Thanks for the reference! I'm just thinking out loud here, but would creating a manual users table where users are added manually and then adding document level rules for it be a good idea? Would love to know your opinion on this. Thanks for your response πŸ˜„

Drake
17 Jun, 2023, 21:05

I don't think you can create document level rules like that.

Have you tried using Appwrite's oauth instead of the apple sign in button?

SaurabhJamadagni
18 Jun, 2023, 15:37

Yes, I am using email as an option for authentication. Was just wondering about sign in with apple as including any social logins on iOS requires having an sign in with apple option as well.

Drake
18 Jun, 2023, 15:54

That would just be styling it to look the same

SaurabhJamadagni
19 Jun, 2023, 18:56

Ahhh. Okay thank you so much for your help! I'll look into it this way

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more