A local webserver for answering OAuth callbacks
OAuth is an increasingly popular system for authenticating client software to Internet services, but it often requires coordination with a webserver hosted by the client's developer. When the client software is an Open Source project running on a user's computer and without any external supporting infrastructure, this can present a difficult obstacle.
This package provides a standard framework for writing OAuth callback handlers and running them on a local webserver temporarily set up for just that purpose.
Authenticating to an App.net server:
>>> from oauthcallback.appdotnet import AppDotNetHandler
>>> token_info = AppDotNetHandler.fetch_access_token(
... client_id='XJtBFQwBesZHYE4TGcFwzvfq6D6a7NCa',
... scope='stream,public_messages')
>>> token_info['access_token']
'BigLongAlphanumericString'
You now have a token for accessing the user's account resources.
Subclass CallbackHandler
method's:
-
auth_url
returns the URL that the user's web browser will initially open with. -
do_Get
analyzes the callback request to parse out the access token or other relevant data. Callself.finish_with_result
to stop the web server and return the results to the client program.
Python OAuth Callback is available under the MIT License.