-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.py
38 lines (31 loc) · 1012 Bytes
/
provider.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'''
provider module for managing provider OAuth and callback routes
'''
from flask import redirect
from oauth import OAuthSignIn
from db_access import save_access_token_to_db
def oauth_authorize(provider):
'''
'''
oauth = OAuthSignIn.get_provider(provider)
return oauth.authorize()
def oauth_callback(provider):
'''
'''
# if not current_user.is_anonymous:
# return redirect(url_for('index'))
oauth = OAuthSignIn.get_provider(provider)
provider_user_id, access_token = oauth.callback()
# user_id, token, provider, provider_user_id=None
# save_access_token_to_db()
print(provider_user_id, access_token)
# if social_id is None:
# flash('Authentication failed.')
# return redirect(url_for('index'))
# user = User.query.filter_by(social_id=social_id).first()
# if not user:
# user = User(social_id=social_id, nickname=username, email=email)
# db.session.add(user)
# db.session.commit()
# login_user(user, True)
return redirect('http://localhost:3000')