expo-apple-authentication 没有电子邮件地址

问题描述 投票:0回答:1

我正在将 SSO 实施到移动应用程序中。我已设置并运行 Google SSO,现在只需要完成 Apple 的工作。

我只需要弄清楚最后一件事就可以了。我第一次尝试使用 Apple 登录时,我在结构中收到了响应:

{
  authorizationCode: '...',
  email: null,
  fullName: {
    familyName: null,
    givenName: null,
    middleName: null,
    namePrefix: null,
    nameSuffix: null,
    nickname: null,
  },
  identityToken: '...',
  realUserStatus: 1,
  state: null,
  user: '...',
}

我现在的问题是,当我尝试使用 Apple 登录时,我没有在 Apple 的响应中收到

email
。有谁知道如何解决或克服这个问题?

我的

signInWithApple
功能如下:

import * as AppleAuthentication from 'expo-apple-authentication'

const signInWithApple = async () => {
  try {
    const userInfo = await AppleAuthentication.signInAsync({
      requestedScopes: [AppleAuthentication.AppleAuthenticationScope.EMAIL],
    })
    return userInfo
  } catch (error) {
    throw error.code
  }
}

export default signInWithApple

编辑

我在网上看到有人提到解码

identityToken
,这确实给了我电子邮件地址,现在只想确认这是否是正确的做法?

react-native expo single-sign-on apple-sign-in apple-sso
1个回答
0
投票

这在另一篇文章中得到了回答:带有名称和邮件范围的ASAuthorizationAppleIDRequest返回零值

TLDR;

  • 这是预期行为,fullName 属性仅返回一次。您应该缓存初始响应,以防出现错误并在创建用户帐户时使用它,或者解码 JWT 将获得电子邮件。
  • 在设备上,您可以在 iCloud 设置 -> 登录和安全 -> 使用 Apple 登录中删除应用程序的“通过 Apple 登录”,以便将流程重置为“创建流程”
  • 在模拟器上,您需要从 iCloud 注销才能重新启动流程

再次强调,来自 TLDR 的所有信息都在链接的帖子中:)

  • 在 iOS 模拟器中
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.