【发布时间】:2020-03-03 18:11:06
【问题描述】:
前缀:我是 django 新手。
堆栈:oAuth2 + PKCE 协议、Angular、Django-oauth2-toolkit + REST
继续获取:
oauthlib.oauth2.rfc6749.errors.InvalidRequestError: (invalid_request) URL query parameters are not allowed <oauthlib.Request SANITIZED>
没有关于请求内容的错误细节。
当我在 Angular 中使用 pkce 格式的 POST 请求访问 django oauth2 服务器时,例如
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/',
{
headers: new HttpHeaders({'Content-Type': 'application/x-www-form-urlencoded'})
},
{
params:
new HttpParams()
.set('grant_type', 'authorization_code')
.set('code', code)
.set('redirect_uri', 'http://localhost:4200/dashboard')
.set('client_id', 'CLIENT_ID')
.set('state', state)
.set('verifier', verifier)
});
}
不知道出了什么问题。
P.S 在 django 日志中打印请求时,看起来没有任何编码。挑战和验证者正在工作,否则错误将表明如此。
【问题讨论】:
标签: python-3.x angular django-rest-framework oauth-2.0 pkce