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

Python create-tweet example missing `?oauth_callback=oob` #73

Closed zmoon closed 2 years ago

zmoon commented 2 years ago

In order to get the example to work, I had to add that to the end of this URL:

https://github.com/twitterdev/Twitter-API-v2-sample-code/blob/653248e62ae9c579d0c12e82c1566352bef9bdf7/Manage-Tweets/create_tweet.py#L16

The JS example does have it:

https://github.com/twitterdev/Twitter-API-v2-sample-code/blob/653248e62ae9c579d0c12e82c1566352bef9bdf7/Manage-Tweets/create_tweet.js#L29

timborden commented 2 years ago

Nice find!

I needed to add an extra x_auth_access_type query parameter to get write access:

request_token_url = "https://api.twitter.com/oauth/request_token?oauth_callback=oob&x_auth_access_type=write"

Source: https://developer.twitter.com/en/docs/authentication/api-reference/request_token

zmoon commented 2 years ago

@timborden good to know. I guess I didn't need that because I changed my OAuth settings in Developer Portal from the default read to read/write?

JessicaGarson commented 2 years ago

Thanks, @zmoon @timborden, for your feedback. I'm looking into this and will make some changes here if needed.

JessicaGarson commented 2 years ago

All versions of this code work for me, but I'm going to go ahead and update all the samples with https://api.twitter.com/oauth/request_token?oauth_callback=oob&x_auth_access_type=write. Thank you for this feedback.

zmoon commented 2 years ago

@JessicaGarson any idea why oauth_callback=oob wasn't needed for you? This page makes it sound like it is always needed in this situation.

If you are using pin-based authorization, you will need to set this to oob.

JessicaGarson commented 2 years ago

I think this has to do with some settings on our end, and I know this code worked for some users. I'm still working on getting to the bottom of it, but I'll let you know if I hear of anything. Also worth noting that we've made some auth changes since that page was initially created.

JessicaGarson commented 2 years ago

I'm going to close out this issue since these issues have been resolved.