
I am trying to add Sign in with Apple to my app. I added the AppID, Service ID, etc in the developer's portal. I also configured the Appwrite to enable the Sign in with Apple service. I used the Service ID (Not the bundle ID) in the AppWrite's Apple OAuth. I write the following code in the SignInWithAppleButton's onCompletion closure.
do {
_ = try await account.createOAuth2Session(provider: .apple, scopes: ["email", "fullName"])
print("Successfully signed in with Apple!")
} catch {
print("Failed to create session: \(error.localizedDescription)")
}
The app ends up opening up the sign in sheet in the app -> Pop to website -> Sheet appears again -> go back to the app. Not only this weird problem, here are some more:
- I can trap the callback with .onOpenURL in the SwiftUI view. But it is kind of weird and not sure whether the user has been logged in successfully or not. How to do that properly?
- I can see the Apple ID is being added to the AppWrite Auth's user list. but it only able to track the email not the name. Would I be able to do that?
I tried to search the internet tutorial but most of them are for SignInWithApple + Web App. I can't find any proper tutorial for native SwiftUI app. If any info you have may help, please feel free to let me know.

After sign in a session is created. so you can use account.get() to get current session and userID

Its weird how this is configured.
- You are probably using native sign-in [the first oauth modal]
- On completion, you are triggering another OAuth that takes you to Safari.
You don't need #1 here.
See - https://appwrite.io/docs/products/auth/oauth2
Select Apple
in the language selector.

Do you mean I should not use the native siginwithapplebutton?

I tried to switch to NOT use the native SignInWithApple button. It just switch to the Safari every single time.

Have you find the solution? I’m with the same problem and can’t be redirected to my app once the user is signed in, it just remains in the same state
Recommended threads
- Custom document types in Swift
How would I create a protocol to conform to Models.Document?
- Document Data is null.
I'm using flutter and I've just got everything set up, the document meta data is null but the actual query is fine. (see screenshot) The permission I have ar...
- Swift: Delete All Documents
In Swift, how does one delete all documents in the collection. Is the solution to iterate over each document to delete it by document id? Or is there a .deleteA...
