Skip to content
New issue

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

After Revoking Apple ID (Stop Using Apple ID) not getting full name and email on next login attempt #340

Open
michaelbrant opened this issue Jan 18, 2024 · 15 comments

Comments

@michaelbrant
Copy link

michaelbrant commented Jan 18, 2024

The FAQs say that in order to receive the full name and email again, you must revoke Apple ID access for the app. After logging out of the app, revoking Apple ID access (Settings > Apple ID > Sign-In & Security > Sign in with apple > My App > Stop Using Apple ID), and then logging in again, I'm still not seeing full name and email in the response. I was also expecting to be prompted to share/ hide my email address but that didn't pop up either.

Here is the code:

async function signInOrRegisterWithApple() {
  const appleAuthRequestResponse = await appleAuth.performRequest({
    requestedOperation: appleAuth.Operation.LOGIN,
    requestedScopes: [appleAuth.Scope.FULL_NAME, appleAuth.Scope.EMAIL],
  });

  const { identityToken, nonce, email, fullName } = appleAuthRequestResponse;

  if (identityToken) {
    const appleCredential = firebase.auth.AppleAuthProvider.credential(identityToken, nonce);

    const user = await firebase.auth().signInWithCredential(appleCredential);

    console.warn(`These values are empty: ${email} ${fullName?.givenName}`);
  } 
}

Other things I've tried:

  1. Made sure the order of requestedScopes had Full name first
  2. Uninstalled the app and reinstalled + revoke Apple ID access while uninstalled
  3. Posted in Apple Community
  4. I've tried to revoke the token, at first I was getting[Error: [auth/invalid-credential] The supplied auth credential is malformed or has expired.] but realized this was because I was using firebase local auth emulator. After switching to the hosted firebase auth, revokeToken did work successfully, however, the main problem still persists.
async function revokeSignInWithAppleToken() {
  const { authorizationCode } = await appleAuth.performRequest({
    requestedOperation: appleAuth.Operation.REFRESH,
  });

  if (!authorizationCode) {
    throw new Error("Apple Revocation failed - no authorizationCode returned");
  }

  // Revoke the token
  return auth().revokeToken(authorizationCode);
}
@mikehardy
Copy link
Collaborator

Unexpected. Do you have version information of all the components of the system under test (device model number, device operating system, relevant package versions from package.json, xcode version etc)? https://stackoverflow.com/help/how-to-ask

The FAQ you list was developed via experience / test results from users of the library. I personally did not do the testing or observe the results so I don't have the experience to say if it used to work correctly or not. I also do not have time to do the testing now, with apologies.

I'm open to any PR either updating documentation or altering code as needed depending on what you learn via testing and/or any responses you get from the Apple discussions

@wordisthebird
Copy link

any update on this?

@MayurMax4
Copy link

hi team,
we are also getting the same issue, where email is also not coming after successful authentication. Currently using the version 2.3.0.
Any suggestion will be helpful..

@azulay7
Copy link

azulay7 commented Apr 30, 2024

I waiting also for some solution.
appleAuth.performRequest response does not contains any personal value

@siquick
Copy link

siquick commented May 2, 2024

Also suddenly getting this issue of no displayName or email. Using version 2.3.0 of library.

Have tried the following:

  • Settings > Apple ID, iCloud, iTunes & App Store > Password & Security > Apps Using Your Apple ID, tap on your app and tap Stop Using Apple ID
  • Changed app identifier and re-established all credentials from Firebase.

Email address is now also not being stored in Firebase.

Code for Apple Sign In

const appleAuthRequestResponse = await appleAuth.performRequest({
      requestedOperation: appleAuth.Operation.LOGIN,
      requestedScopes: [appleAuth.Scope.FULL_NAME, appleAuth.Scope.EMAIL],
});

@turkmenkaan
Copy link

We're having the same issue here. Any update would be very appreciated

@turkmenkaan
Copy link

After checking Apple Settings > Sign In, we noticed that the token was not actually revoked in the first place. That's probably why you're not receiving user information upon next login. Not sure what's wrong with the revokeToken method though, it seems to not resolve the promise.

@siquick
Copy link

siquick commented May 10, 2024

I have managed to get the Apple token revoking by following these setup instructions closely and using this function.

export const deleteAppleUser = async (): Promise<ReturnType> => {
	try {
		// Get an authorizationCode from Apple
		const { authorizationCode } = await appleAuth.performRequest({
			requestedOperation: appleAuth.Operation.REFRESH,
		});

		// Ensure Apple returned an authorizationCode
		if (!authorizationCode) {
			throw new Error("Apple Revocation failed - no authorizationCode returned");
		}

		const result = await auth().revokeToken(authorizationCode);

		return { result, error: null };
	} catch (error) {
		Sentry.captureException(error);
		return { result: null, error };
	}
};

The problem I'm having now is that, even for new users, I am no longer getting the users name, only the email address.

This is my JS function for Sign In

async function onAppleButtonPress() {
		try {
			// Start the sign-in request
			const appleAuthRequestResponse = await appleAuth.performRequest({
				requestedOperation: appleAuth.Operation.LOGIN,
				requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME],
			});

			// Ensure Apple returned a user identityToken
			if (!appleAuthRequestResponse.identityToken) {
				throw new Error("Apple Sign-In failed - no identify token returned");
			}

			// Create a Firebase credential from the response
			const { identityToken, nonce } = appleAuthRequestResponse;
			const appleCredential = auth.AppleAuthProvider.credential(identityToken, nonce);

			// Sign the user in with the credential
			return await auth().signInWithCredential(appleCredential);

		} catch (error) {
			console.error(error);
			return { result: null, error };
	}

@Daniel3711997
Copy link

The issue still persist

@thangpaisen
Copy link

I also encountered this problem in version 2.3.0
Using version 2.2.2 the problem was resolved

@sqpollen
Copy link

I am now getting the fullName after the user revokes their access. However, it does not get saved to the user record in Firebase unless I systematically update the profile. Is there a better way to do this than calling auth().currentUser.updateProfile?

const appleAuthRequestResponse = await appleAuth.performRequest({
    requestedOperation: appleAuth.Operation.LOGIN,
    requestedScopes: [appleAuth.Scope.FULL_NAME, appleAuth.Scope.EMAIL],
});

// Ensure Apple returned a user identityToken
if (!appleAuthRequestResponse.identityToken) {
throw new Error("Apple Sign-In failed - no identify token returned");
}

// Create a Firebase credential from the response
const { identityToken, nonce, fullName } = appleAuthRequestResponse;
const appleCredential = auth.AppleAuthProvider.credential(identityToken, nonce);

const userCredential = await auth().signInWithCredential(appleCredential);

//Update the profile with the fullName
if (fullName) {
  const update = {
	  displayName: `${fullName.givenName} ${fullName.familyName}`,
	  photoURL: "",
  };
  await auth().currentUser.updateProfile(update);

}

@moustafahelmi96
Copy link

have the same issue

1 similar comment
@MrNapcae
Copy link

have the same issue

@aboveStars
Copy link

aboveStars commented Jul 26, 2024

Having the same issue.
Edit: I realized that this issue only exists on iOS Simulators not on real devices.

@nroV
Copy link

nroV commented Sep 16, 2024

any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests