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

The user email is shared only once #24

Open
marcusdiy opened this issue Jul 30, 2020 · 7 comments
Open

The user email is shared only once #24

marcusdiy opened this issue Jul 30, 2020 · 7 comments

Comments

@marcusdiy
Copy link

Hi, Is it normal that the user email is showed only on the first sign up?
...on the following logins it will be just and empty string.
Thanks

@marcusdiy
Copy link
Author

Uh ok seems the expected behavior. https://developer.apple.com/forums/thread/121496
But I think some kind of internal plugin cache would be better. What do you think?

@azurenote
Copy link

I've faced same problem few days ago.
personally I use NativeStorage to cache user's email.
It just work but Idk it is proper way.

@frissonlabs
Copy link

Using NativeStorage doesn't suffice: if the user uninstalls and reinstalls the app (thus clearing NativeStorage), the device still stores the Apple Sign In configuration from the first time. Hence, on reinstall, it will be treated as just another login and, since NativeStorage was cleared), the app has no way of every retrieving the email again. The user would have to manually go into Settings->Apple ID->Password & Security->Apps Using Apple ID->{appName} and then tap on "Stop Using Apple ID". This is probably not the best way to handle this.

@faugusztin
Copy link

The only reliable solution is to communicate the token to your backend servers, which then communicates to Apple servers, where you get the email on every request:
https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple
https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens

Not sure if it is valid, secure or even possible (i mean without rejection in App Store review) to communicate with Apple REST API directly from the application, without a intermediate backend.

@zhicheng-Fu
Copy link

zhicheng-Fu commented Oct 22, 2020

window.cordova.plugins.SignInWithApple.signin({ requestedScopes: [0, 1] }, function (succ) {
let jwt = succ.identityToken;
let decoded = jwt_decode(jwt);
console.log(decodedl);
console.log(decoded.email);
}, function (err) {
console.error(err)
console.log(JSON.stringify(err))
}
)

@frissonlabs
Copy link

@zhicheng-Fu Thanks, this addresses this issue perfectly!

@menusha95
Copy link

menusha95 commented Nov 23, 2020

window.cordova.plugins.SignInWithApple.signin({ requestedScopes: [0, 1] }, function (succ) {
let jwt = succ.identityToken;
let decoded = jwt_decode(jwt);
console.log(decodedl);
console.log(decoded.email);
}, function (err) {
console.error(err)
console.log(JSON.stringify(err))
}
)
This should be the accepted answer.

for jwt_decode use this
https://www.npmjs.com/package/jwt-decode

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

6 participants