错误:";不支持的“U型授权”;来自django oauth2服务器
不确定django为什么不接受我对访问令牌的POST请求。我的所有参数都是正确的,并且我已经有了授权代码,但是访问令牌的后续POST请求给了我这个错误 从我从其他人那里读到的内容类型是正确的。如果pkce方面不准确,它会给我一个更具体的错误 HttpErrorResponse是错误:";不支持的“U型授权”;来自django oauth2服务器,django,angular,oauth-2.0,Django,Angular,Oauth 2.0,不确定django为什么不接受我对访问令牌的POST请求。我的所有参数都是正确的,并且我已经有了授权代码,但是访问令牌的后续POST请求给了我这个错误 从我从其他人那里读到的内容类型是正确的。如果pkce方面不准确,它会给我一个更具体的错误 HttpErrorResponse是 {error:“unsupported_grant_type”}400错误请求 requestToken(code: string, state: string) { const clientState = ses
{error:“unsupported_grant_type”}400错误请求
requestToken(code: string, state: string) {
const clientState = sessionStorage.getItem('pkce-state');
if (clientState !== state) {
console.error('States do not match!');
}
const verifier = sessionStorage.getItem('pkce-verifier');
const params = new URLSearchParams({
grant_type: 'authorization_code',
redirect_uri: 'http://localhost:4200/dashboard',
client_id: 'client_id',
code,
state,
verifier
});
return this.http.post('http://localhost:8000/o/token/',
{
params
},
{
withCredentials: true,
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
}
)
});
}
我也试过:
requestToken(code: string, state: string) {
const clientState = sessionStorage.getItem('pkce-state');
if (clientState !== state) {
console.error('States do not match!');
}
const verifier = sessionStorage.getItem('pkce-verifier');
return this.http.post('http://localhost:8000/o/token/',
{
grant_type: 'authorization_code',
redirect_uri: 'http://localhost:4200/dashboard',
client_id: 'client_id',
code,
state,
verifier
},
{
withCredentials: true,
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
}
)
});
}尝试匹配:
- 使用代码验证程序
- 去掉state参数,在直接发送到令牌端点的https消息中不需要该参数
再说一次,Django始终可能不正确支持此流…我同意您的建议@Gary Archer。看起来没有变化。无论如何,谢谢你。