Не знаю, почему django не принимает мой запрос POST для токена доступа. Все мои параметры верны, и у меня уже есть код авторизации, но последующий запрос POST для токена доступа выдает мне эту ошибку.
Тип содержимого правильный из того, что я прочитал у других. Если бы сторона pkce была неточной, это дало бы мне более конкретную c ошибку об этом.
HttpErrorResponse равен { error: "unsupported_grant_type" } 400 bad request
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'
}
)
});
}