关于苹果授权,官方文档写的不仔细,但还是要看一下 https://developer.apple.com/sign-in-with-apple/get-started/
后端验证苹果授权用户正确性有两种方式,如下: 利用 identity_token 与 user_id 进行校验,匹配成功,即证明 user_id 是正确的唯一标识。 利用授权 code,加生成 client_secret,进行授权验证。 一、验证 identity_token 与 user_id (建议使用,方便) 安装PHP扩展包(支持php5.6及以上):composer require wubuwei/php-apple-signin 使用方式见:https://github.com/wubuwei/php-apple-signin a. mac 电脑安装 ruby 环境+ ruby-jwt 扩展:brew install ruby 、sudo gem install jwt
b. 配置 client-secret.rb 参数。
c. 执行命令:ruby client-secret.rb 文件 生成 token,即后端解密用的 client_sercret
如何解密 code: 后端验证的目的就是为了保证客户端授权后传给后端的 user_id 为正确的 Apple Id 授权后的唯一标识,然后就可以用这个唯一标识来做账户关联等一系列操作,类似于微信授权后的 open_id。