-
-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #497 from requests/pkce
Add PKCE support with oauthlib 3.2.0
- Loading branch information
Showing
6 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ Examples | |
github | ||
native_spa_pkce_auth0 | ||
outlook | ||
spotify | ||
tumblr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
client_id = 'your_client_id' | ||
|
||
authorization_base_url = "https://dev-foobar.eu.auth0.com/authorize" | ||
token_url = "https://dev-foobar.eu.auth0.com/oauth/token" | ||
scope = ["openid"] | ||
|
||
from requests_oauthlib import OAuth2Session | ||
redirect_uri = 'http://localhost:8080/callback' | ||
|
||
session = OAuth2Session(client_id, scope=scope, redirect_uri=redirect_uri, pkce="S256") | ||
authorization_url, state = session.authorization_url(authorization_base_url,access_type="offline") | ||
|
||
print("Please go here and authorize:") | ||
print(authorization_url) | ||
|
||
redirect_response = input('Paste the full redirect URL here: ') | ||
|
||
token = session.fetch_token(token_url, authorization_response=redirect_response, include_client_id=True) | ||
print(token) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Native or SPA Tutorial with PKCE in Auth0 | ||
========================================= | ||
|
||
Setup a new web project in the Auth0 Dashboard, (application type: Native application or Single Page Web Application)_ | ||
|
||
Note this sample is valid for any Identity Providers supporting OAuth2.0 Authorization Code with PKCE. | ||
|
||
When you have obtained a ``client_id``, and registered | ||
a callback URL then you can try out the command line interactive example below. | ||
|
||
.. literalinclude:: native_spa_pkce_auth0.py | ||
:language: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters