我正在将 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
,这确实给了我电子邮件地址,现在只想确认这是否是正确的做法?
这在另一篇文章中得到了回答:带有名称和邮件范围的ASAuthorizationAppleIDRequest返回零值
TLDR;
再次强调,来自 TLDR 的所有信息都在链接的帖子中:)