在苹果身份验证期间获取电子邮件 ID 值 null 作为响应 [英] Getting email id value null as response during apple-authentication

查看:34
本文介绍了在苹果身份验证期间获取电子邮件 ID 值 null 作为响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 expo-apple-authentication 包在 react native 中实现苹果身份验证.

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

下面是我在按钮的 onPress 上调用的代码.

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
        }
      }
  }

它应该返回我在范围内请求的身份验证令牌、Full_Name 和电子邮件,但它给我的 Full_Name 和电子邮件 null.

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.

推荐答案

根据文档:

requestedScopes (AppleAuthenticationScope[])(可选)- 您的应用请求访问的用户信息范围数组.请注意,用户可以在登录时选择拒绝您的应用访问任何范围.您仍然需要为您请求的任何范围处理空值.另外,请注意,请求的范围只会在每个用户第一次登录您的应用时提供给您;在随后的请求中,它们将为空.

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.

您可能已经登录过一次并且没有看到日志.后续登录将导致该数据为null

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

这篇关于在苹果身份验证期间获取电子邮件 ID 值 null 作为响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆