I am trying to use the PKCE flow for the user authentication.
After successful redirection by using the following pattern:
I got the code, but then when I try to get the access token the following request fails:
curl --location --request POST 'https://api.twitter.com/2/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic <base 64 encode>' \
--data-urlencode 'code=<code received>' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'redirect_uri=<my_redirect>' \
--data-urlencode 'code_verifier=challenge' \
--data-urlencode 'client_id=<my_client_id>'
Run Code Online (Sandbox Code Playgroud)
Error message is {"error":"unauthorized_client","error_description":"Missing valid authorization header"}
I tried to use all of the methods described here for the Basic header, but none of them were successful:
https://twittercommunity.com/t/how-to-generate-a-bear-token-for-api-2-authentication/171837
Thanks!
小智 11
在您的应用程序 > 用户身份验证设置 > 单击 OAuth 1.0a 和 OAuth 2.0 的编辑 > 打开 OAuth 1.0a 和 OAuth 2.0 并将应用程序类型更改为“单页应用程序”,该应用程序应该是公共客户端。
| 归档时间: |
|
| 查看次数: |
2353 次 |
| 最近记录: |