Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged with hybridgroup's Client2 version #109

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,19 @@ Gmail supports OAuth over IMAP and SMTP via a standard they call XOAUTH. This al
conn.authenticate(url, consumer, token)


# OAuth2 Example

You might have thought from the name "oauth2" that this libary supported
the OAuth2 standard. You would have been wrong, except for the fine efforts
of https://github.com/dgouldin. Here is how you use it:

import oauth2
client = oauth2.Client2(CONSUMER_KEY, CONSUMER_SECRET, AUTHORIZATION_URL)
auth_url = client.authorization_url(redirect_uri = CALLBACK_URL)
print auth_url
# navigate to auth_url, to obtain code
token = client.access_token(code, CALLBACK_URL, endpoint='token')["access_token"]
print token
# use token to call secure APIs
(headers, content) = client.request(RESOURCE_URL, access_token=token)
...
Loading