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

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

问题描述

我正在使用expo-apple-authentication包在react native中实现apple-authentication.

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和Email的空值.

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.

您可能已经登录过一次,但没有捕获日志.后续登录将导致该数据为

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

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

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