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>'
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!