xdevplatform / Twitter-API-v2-sample-code

Sample code for the Twitter API v2 endpoints
https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api
Apache License 2.0
2.65k stars 984 forks source link

Isnt there any way to automate the entire authentication process while creating a tweet? #89

Closed hDmtP closed 2 years ago

hDmtP commented 2 years ago

https://github.com/twitterdev/Twitter-API-v2-sample-code/blob/aa131cfa3ee2d440db22fb9f1753374b26b7125b/Manage-Tweets/create_tweet.py#L34

I have to manually visit the authentication link and copy-paste the verifier pin in terminal. Isn't consumer_key and consumer_secret enough to authenticate these whole process?

Do I need an elevated access to do it?

andypiper commented 2 years ago

The consumer key and secret identify your app. This is OK for read-only functions like getting a public Tweet, or searching for Tweets. For functions where you need to post, you will need additional values that enable your app to post as an authenticated user.

The PIN-based approach enables the code to do the sign-in and get a usable pair of access token and access token secret. If you were coding this yourself, you could build the sign-in flow and cache/save the access token and access token and secret. This code is just a single example to demonstrate one method of getting tokens to enable you to post a Tweet.

hDmtP commented 2 years ago

Thanks for pointing it out. I will try it...

360macky commented 1 year ago

Hi @hDmtP! Please, how did you solve this? 🙏 I also wonder the same thing as you, and I'm just starting with this API.

rodrigorootrj commented 1 year ago

i don't understand it, is it standard to v2 api, puts handly a number get from website? this is nonsense. I have a limit by day. Is It, not enough?