mastervv
mastervv

Reputation: 402

Access to api.twitter.com/2/users/:id/following as a user

I'm try to request call this route api.twitter.com/2/users/:id/following also getting the error :

Authenticating with OAuth 2.0 Application-Only is forbidden for this endpoint. Supported authentication types are [OAuth 1.0a User Context, OAuth 2.0 User Context].

I've trying to understand how I should generate an oauth token valid for this request, but i'm a bit lost! I've all the pipe line for the user authentication and for the last request I can get all user data including userToken and tokenSecret how i can use that info to generate the token for my request?

Also I've try to generate a token generate with apiKey and apiSecret withtou success

curl -u 'apiKey:apiSecret' \
  --data 'grant_type=client_credentials' \
  'https://api.twitter.com/oauth2/token'

I'm really lost using twitter api because of the multiples ways to authenticate

Upvotes: 2

Views: 3990

Answers (1)

Alan Lee
Alan Lee

Reputation: 19

The curl command you're using will give an App-Only token, this won't work if you're trying the POST /2/users/:id/following endpoint. Follow this guide on generating an OAuth 2.0 User Access Token.

Upvotes: 0

Related Questions