Back

How do I properly setup OAuth2 flow for my iOS app using Google?

  • 0
  • Self Hosted
  • Auth
  • Apple
Ivan Bogdantsev
30 Nov, 2024, 19:34

This is a duplicate of now closed thread [ CLOSE ] How do I connect Google oauth2 to my ios app? with a more precisely formulated question

Hello everyone! I'm a bit confused about the proper way to authenticate users via third-party providers that I should choose. Let me clarify: I spent quite some time in a closed thread mentioned above, where @Gurjeet was desperately trying to help me. Unfortunately, it seems my question was so convoluted that we couldn't arrive at a solution (apologies to @Gurjeet). I also spent a lot of time reading the documentation but couldn't find an answer to my question.

I want to use the native user authentication method provided by Google Sign-In SDK for iOS. As you know, upon successful authentication, this SDK will return userID and userEmail. Here's the question: how do I create a user account in Appwrite using these parameters?

Is there a definitive and proper way to achieve this? The issue is that the methods in the iOS SDK from Appwrite do not allow creating a user without a password parameter, nor do they allow creating a session for such a user.

I would greatly appreciate a step-by-step guide on what to do with the userID and userEmail provided by Google to create a user in Appwrite and subsequently create a session for that user.

Why am I asking this?
I tried setting up the OAuth2 flow following the Appwrite instructions (Appwrite OAuth Google Integration), but I ran into two issues:

  1. The auth flow happens in a separate instance of Safari, which is not user-friendly compared to the sign-in flow from Google Sign-In SDK, where Safari opens modularly within the app.
  2. The redirect URI sends the user to a blank page, even though I (presumably) configured everything correctly and double-checked all parameters multiple times (I’m using self-hosted Appwrite on gitpod.io).
TL;DR
Developers need help setting up OAuth2 flow for iOS app with Google Sign-In SDK and Appwrite User API. They are unsure about creating a user account in Appwrite using Google's `userID` and `userEmail`. The iOS SDK from Appwrite doesn't allow creating a user without a password parameter or creating a session for such a user. They are looking for a step-by-step guide on how to use the Google parameters to create a user in Appwrite and establish a session. **Solution:** The user can try using the Google Sign-In SDK for authentication and then, after obtaining the `userID` and `userEmail`, manually
Ivan Bogdantsev
30 Nov, 2024, 19:34

Because of this, I wanted to try linking the Google Sign-In SDK auth flow with the User API from Appwrite.

One of my ideas was to create a user using their userID as the password, but I think this is a hacky and incorrect approach.

Thanks in advance for your help!

Guri
30 Nov, 2024, 19:40

hey @Darshan Pandya need your help here. I'm not very familiar with iOS, but I did try to look into it, and I think you're right about this one. Could you please take a look and help out?

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