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? #337

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)

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