我想用social auth python制作一个apple登录。现在我有一段代码在下面。当我做请求时,我得到一个无效的授权错误。我认为“id_令牌”无效。但我不知道如何获取id_令牌,因为我在请求之后获取id_令牌。有人能帮我吗。非常感谢
headers = {
'alg': 'ES256',
'kid': settings.SOCIAL_AUTH_APPLE_ID_KEY
}
payload = {
'iss': settings.SOCIAL_AUTH_APPLE_ID_TEAM,
'iat': now,
'exp': now + TOKEN_TTL_SEC,
'aud': 'https://appleid.apple.com',
'sub': settings.SOCIAL_AUTH_APPLE_ID_CLIENT,
}
client_secret = jwt.encode(
payload,
settings.SOCIAL_AUTH_APPLE_ID_SECRET,
algorithm='ES256',
headers=headers
).decode("utf-8")
headers = {'content-type': "application/x-www-form-urlencoded"}
data = {
'client_id': 'com.scread.app',
'client_secret': client_secret,
'code': 'id_token',
'grant_type': 'authorization_code'
}
res = requests.post('https://appleid.apple.com/auth/token', data=data, headers=headers)
似乎服务id必须以.app结尾。例如com.company.app。这就是我的解决办法
相关问题 更多 >
编程相关推荐