invertase / react-native-apple-authentication

A React Native library providing support for Apple Authentication on iOS and Android.
Other
1.36k stars 215 forks source link

How to extract email from an Apple login's token? #338

Closed kdn0325 closed 6 months ago

kdn0325 commented 6 months ago
import { appleAuth } from '@invertase/react-native-apple-authentication';
import jwt_decode from 'jwt-decode';

const appleAuthRequestResponse = await appleAuth.performRequest({
  requestedOperation: appleAuth.Operation.LOGIN,
  requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME]
});
// other fields are available, but full name is not
const { email, email_verified, is_private_email, sub } = jwt_decode(appleAuthRequestResponse.identityToken)

ERROR : [InvalidTokenError: Invalid token specified: invalid base64 for part #2 (Property 'atob' doesn't exist)]

I am implementing Apple login using react-native and need to extract the email value of the user, so I am using jwt-decode to read the token file and read the email value. How do I extract the token file from react-native? The library you use is

"react-native": "0.71.2",
"@invertase/react-native-apple-authentication": "^2.2.2",
"jwt-decode": "^4.0.0",

Please help me

mikehardy commented 6 months ago

You'll need stackoverflow. We provide the software and if you can point to a bug in the module we'll merge+release PRs and work towards fixes but general support for programming items is a stackoverflow thing

Parkjunwu commented 5 months ago

jwt-decode downgrade to v3