Skip to content

kstrauser/PythonOAuthCallback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python OAuth Callback

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.

Example

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.

Writing your own handler

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. Call self.finish_with_result to stop the web server and return the results to the client program.

License

Python OAuth Callback is available under the MIT License.

About

A local webserver for answering OAuth callbacks on localhost

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages