我试图使用python和django 1.9为apple发送身份验证请求,但总是给我不支持的\u grant\u类型

我试图使用python和django 1.9为apple发送身份验证请求,但总是给我不支持的\u grant\u类型,python,django,web-deployment,django-allauth,sign-in-with-apple,Python,Django,Web Deployment,Django Allauth,Sign In With Apple,我试图使用Python和Django 1.9为apple发送身份验证请求,但总是给我不支持的\u grant\u type: def登录苹果(self,code): 苹果url=”https://appleid.apple.com/auth/token" client\u secret=generate\u apple\u client\u secret() adapter=AppleOAuth2Adapter(self.request) headers={'content-type':'app

我试图使用Python和Django 1.9为apple发送身份验证请求,但总是给我
不支持的\u grant\u type

def登录苹果(self,code):
苹果url=”https://appleid.apple.com/auth/token"
client\u secret=generate\u apple\u client\u secret()
adapter=AppleOAuth2Adapter(self.request)
headers={'content-type':'application/x-www-form-urlencoded'}
数据={'client_id':settings.client_id,
“客户机密”:客户机密,
“代码”:代码,
“大类型”:“授权代码”}
resp=requests.post(url=apple\u url,data=data,headers=headers)
访问令牌=无
如果[200201]中的响应状态代码:
尝试:
access_token=resp.json()
除值错误外:
access_token=dict(解析(分别为文本))
如果不访问\u令牌或“访问\u令牌”不在访问\u令牌中:
引发OAuth2错误(
'检索访问令牌时出错:%s'%resp.content
)
返回访问令牌
我如何生成我的
客户端\u密码

def generate_apple_client_secret():
now=datetime.utcnow()
索赔={
“iss”:settings.SOCIAL\u AUTH\u APPLE\u TEAM\u ID,
“澳元”:https://appleid.apple.com',
“iat”:现在,
“exp”:现在+时间增量(天数=180),
“sub”:settings.CLIENT\u ID,
}
headers={'kid':settings.SOCIAL_AUTH_APPLE_KEY_ID'alg':'HS256'}
client_secret=jwt.encode(
有效载荷=声明,密钥=设置。社交验证苹果私钥,
算法='HS256',
**强文本**标题=标题)。解码('utf-8')
返回客户端密码
我正在向苹果发送请求,但总是给我以下错误:

user = self.login_with_apple(ser.instance.token)
File "/home/omar/PycharmProjects/Aswaq/oscarapi/views/login.py", line 488, in  
login_with_apple
Error retrieving access token: %s' % resp.content
OAuth2Error: Error retrieving access token: {"error":"unsupported_grant_type"}