Back

Help complete Apple OAuth for React Native

  • 1
  • React Native
  • Auth
Ceezy’s
21 Jun, 2024, 16:12

Hi there, this is my use case:

Allow an individual to sign up using Apple OAuth, then set up the username, name and age fields for the user collections in the database.

I have configured the "Continue with Apple" button component using Expo Apple Auth and can successfully retrieve the user email. How do I then register the user as an Appwrite auth user and then setup a username, age and name fields?

This is my login component:

TypeScript
<AppleAuthentication.AppleAuthenticationButton
          buttonType={
            AppleAuthentication.AppleAuthenticationButtonType.CONTINUE
          }
          buttonStyle={AppleAuthentication.AppleAuthenticationButtonStyle.BLACK}
          cornerRadius={10}
          style={styles.button}
          onPress={async () => {
            try {
              const credential = await AppleAuthentication.signInAsync({
                requestedScopes: [
                  AppleAuthentication.AppleAuthenticationScope.EMAIL,
                ],
              });
              // signed in
// WHAT AM I SUPPOSED TO DO AFTER GETTING THE CREDENTIALS?
              console.log(credential);
            } catch (e) {
              if (e.code === "ERR_REQUEST_CANCELED") {
              } else {
                // handle other errors
              }
            }
          }}
        />

this is my Appwrite config file that has the create oauth session:

TypeScript
export const createSession = async () => {
  account.createOAuth2Session(OAuthProvider.Apple);
};

How do i essentially connect the two? How do i register this apple id as an auth user and connect them to my user collections? Thank you for your help.

TL;DR
Help needed to integrate Apple OAuth into React Native using Expo Apple Auth. Once the user's email is retrieved, need to register them as an Appwrite auth user and set up username, age, and name fields in the user collections. After retrieving credentials from Apple signInAsync, use Appwrite's createOAuth2Session method to connect the Apple ID to the user collections.
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