Question

I'd like to be able to post tweets from a Python script, that runs from a server cron. I've been following the Twython documentation (https://twython.readthedocs.org/en/latest/usage/starting_out.html#obtain-authorization-url) but i'm not sure if I require a callback_url.

Only pass callback_url to get_authentication_tokens if your application is a Web Application

Desktop and Mobile Applications do not require a callback_url

Does anyone know if I require one? I tried putting in "google.com" but returned a 401 error.

Here's my code currently:

app_name = "AppNameTestScript"

APP_KEY = "exAmPlE"
APP_SECRET = "exAmPlEexAmPlEexAmPlE"

twitter = Twython(APP_KEY, APP_SECRET)
auth = twitter.get_authentication_tokens(callback_url='http://google.com.au')
Was it helpful?

Solution

If you use application-level authorisaion, you should use Oath2 authorisation path

Oath1 authorisation is a bit trickier, your application is authorised to act on behalf of an end user, so the latter has to grant this authority to your application. End user opens auth['auth_url'] url and grants permissions to your app on twitter.com, then he is redirected back to the application, that is where callback is used for. By processing this redirect, a web-based application communicates for access token. Read oauth begguide for more details.

There is a pin-based authoriazation flow in case you can't implement redirect handling. For this, you don't need to provide callback_url, as user acceptance is handled differently. Your end user however still need somehow communicate to your application his pin code. See twython docs for steps starting from when you know pin implementation details

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top