场景: 一旦令牌过期,用户不应注销。
Apple注册步骤:
成功验证授权码并获得成功响应 { “access_token”:“”,“refresh_token”:“”,expires_in:“”}
成功验证从上述步骤获得的 refresh_token 并使用 POST 调用生成新的访问令牌
https://appleid.apple.com/auth/token
问题: 如何从新的访问令牌生成用户数据、id_token?
Apple 生态系统中目前没有UserInfo API。 他们的访问令牌根本没用。
获取用户显示名称的唯一方法是在第一次授权时在回调 url 接收“用户”json 对象。 对于电子邮件,您也可以在 id_token 中获取它。
网址:https://appleid.apple.com/auth/token
要求:
{
client_id : your client_ID
client_secret : JWT_token
code : Authentication code (provided when login with Apple, which is expired within 5 minutes)
grant_type : authorization_code
redirect_uri : provided in “Return URL” when creating “Services ID” in Apple account
}
网址:https://appleid.apple.com/auth/token
要求:
{
client_id : your client_ID
client_secret : JWT_token
grant_type : refresh_token
refresh_token : refresh_token received in step - 1 API response
}
刷新令牌是终身有效令牌,但当用户更改密码/用户进行的任何其他使会话更改的操作时失效。 因此,在这种情况下,您需要重新登录以获取新的刷新令牌。