app授权登录后 等到 identityToken 的exp时间超过之后 继续调用 uni.login 获取到的 identityToken 还是旧的 identityToken
uni.login({provider: "apple"})
如果卸载APP重新安装就能拿到新的 identityToken
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: macOS Ventura 13.4.1 (22F82)
HBuilderX类型: 正式
HBuilderX版本号: 3.8.6
手机系统: iOS
手机系统版本号: iOS 15
手机厂商: 苹果
手机机型: iphone 6s
页面类型: vue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
app授权登录后 等到 identityToken 的exp时间超过之后 继续调用 uni.login 获取到的 identityToken 还是旧的 identityToken
uni.login({provider: "apple"})
如果卸载APP重新安装就能拿到新的 identityToken
uni.login({provider: "apple"})
使用上面的代码能获取到identityToken,但是identityToken过期之后要返回新的identityToken
第一次获取identityToken的时候是新的,等到 exp时间过了还是返回的第一次的identityToken 导致登录失败
Apple授权登录的identityToken不更新
通过服务器解析后发现
授权登录时间戳:1687918967
identityToken 解析结果
object(stdClass)#11671 (10) {
["iss"]=>
string(25) "https://appleid.apple.com"
["aud"]=>
string(20) "xxxxxxxx"
["exp"]=>
int(1687832456)
["iat"]=>
int(1687746056)
["sub"]=>
string(44) "xxxxxxxxxxxx"
["c_hash"]=>
string(22) "xxxxxxxx"
["email"]=>
string(14) "xxxxxxxxxx"
["email_verified"]=>
string(4) "true"
["auth_time"]=>
int(1687746056)
["nonce_supported"]=>
bool(true)
}
m***@ph233.cn (作者)
已经自行解决,跟朋友讨论后朋友给了一个链接: https://www.html5plus.org/doc/zh_cn/oauth.html#plus.oauth.AuthService 。
经过测试后,问题解决。用户登录之前先调用 apple.logout() ,这样就能拿到新的token了。
// #ifdef APP-PLUS
let apple = null
let auths = {}
plus.oauth.getServices( function (e) {
console.log('getServices', e)
auths = e
apple = auths.find( function (value) {
return value.id === 'apple'
})
if( apple ){
apple.logout()
}
})
// #endif
小小菜76055421
大佬,跟苹果服务端对接的api是那个啊,没找到
2023-06-28 15:32