Getting email id value null as response during apple-authentication

淺唱寂寞╮ 提交于 2021-01-05 09:49:10

问题


I'm implementing apple-authentication in react native using expo-apple-authentication package.

Below is the code which I'm calling on button's onPress.

async handleSocialLogin() {
        const { mutate, BB, onSuccess, navigation } = this.props;
      try {
        const result = await AppleAuthentication.signInAsync({
          requestedScopes: [
            AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
              AppleAuthentication.AppleAuthenticationScope.EMAIL,
          ],
        });        


        Alert.alert(JSON.stringify(result))
        // signed in
      } catch (e) {
        Alert.alert(e)
        if (e.code === 'ERR_CANCELED') {

          // handle that the user canceled the sign-in flow
        } else {
          // handle other errors
        }
      }
  }

It should return me authentication-token, Full_Name and Email which I requested in scope but It is giving me null for Full_Name and Email.


回答1:


As per the documentation:

requestedScopes (AppleAuthenticationScope[]) (optional) - Array of user information scopes to which your app is requesting access. Note that the user can choose to deny your app access to any scope at the time of logging in. You will still need to handle null values for any scopes you request. Additionally, note that the requested scopes will only be provided to you the first time each user signs into your app; in subsequent requests they will be null.

You have probably already logged in once and didn't catch the logs. Subsequent log in will result in this data being null



来源:https://stackoverflow.com/questions/58183091/getting-email-id-value-null-as-response-during-apple-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!