ios Sign In With Apple PHP服务器验证问题

Sign In With Apple服务器登录验证有很多问题,官方文档写的也不清不楚,网上资料不算多。
一、验证identityToken有效性和正确性
根据官方文档说明,identityToken是一个JWT算法格式,要使用JWT这个库去进行解析,解析完成后进行验证:
(1)Verify the JWS E256 signature using the server’s public key
(2)Verify the nonce for the authentication
(3)Verify that the iss field contains https://appleid.apple.com
(4)Verify that the aud field is the developer’s client_id
(5)Verify that the time is earlier than the exp value of the token
具体验证方法可以参考某个博客的一篇文章,我这边验证identityToken都是参考这篇博客

 try {
   
        $identityToken = $verifyArray['identityToken'];
        $appleSignInPayload = ASDecoder::getAppleSignInPayload($identityToken);
        $email = $appleSignInPayload->getEmail();
        $user = $appleSignInPayload->getUser();
        $userId = $verifyArray['user'];
        $isValid = $appleSignInPayload->verifyUser($userId);
//        print_r($isValid);
        if (!$isValid){
   
            if($errDesc ==''){
   
                $errDesc = 'verify userId fail'
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值