-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
127 additions
and
160 deletions.
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
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 |
---|---|---|
@@ -1,26 +1,28 @@ | ||
from flask import Flask, jsonify | ||
from authlib.integrations.flask_client import OAuth | ||
from loginpass import create_flask_blueprint | ||
from loginpass import OAUTH_BACKENDS | ||
from loginpass import Twitter, GitHub, Google | ||
|
||
app = Flask(__name__) | ||
app.config.from_pyfile('config.py') | ||
|
||
|
||
oauth = OAuth(app) | ||
|
||
#: you can customize this part | ||
backends = [Twitter, GitHub, Google] | ||
|
||
|
||
@app.route('/') | ||
def index(): | ||
tpl = '<li><a href="/{}/login">{}</a></li>' | ||
lis = [tpl.format(b.NAME, b.NAME) for b in OAUTH_BACKENDS] | ||
tpl = '<li><a href="/login/{}">{}</a></li>' | ||
lis = [tpl.format(b.NAME, b.NAME) for b in backends] | ||
return '<ul>{}</ul>'.format(''.join(lis)) | ||
|
||
|
||
def handle_authorize(remote, token, user_info): | ||
return jsonify(user_info) | ||
|
||
|
||
for backend in OAUTH_BACKENDS: | ||
bp = create_flask_blueprint(backend, oauth, handle_authorize) | ||
app.register_blueprint(bp, url_prefix='/{}'.format(backend.NAME)) | ||
bp = create_flask_blueprint(backends, oauth, handle_authorize) | ||
app.register_blueprint(bp, url_prefix='') |
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
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
Oops, something went wrong.