From fbb66902ce84917bab26ff884c5884e6a325de44 Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Sat, 9 May 2020 16:34:20 +0530 Subject: [PATCH 01/13] Added oAuth config object --- service/config.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/service/config.py b/service/config.py index 5782582..4f3e7ec 100644 --- a/service/config.py +++ b/service/config.py @@ -28,3 +28,11 @@ class TestConfig(object): SQLALCHEMY_DATABASE_URI = environ.get("TESTING_DATABASE_URL") SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_COMMIT_ON_TEARDOWN = True + +class oAuthConfig(object): + OAUTH_CREDENTIALS = { + "facebook": { + "id": environ.get("FACEBOOK_APP_ID"), + "secret": environ.get("FACEBOOK_APP_SECRET") + } + } From d8f77205f053277d77890c1386868865eec17230 Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Sat, 9 May 2020 16:34:46 +0530 Subject: [PATCH 02/13] Modified DB Model to handle oAuth --- service/api/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/service/api/models.py b/service/api/models.py index 13c20f6..54dddc4 100644 --- a/service/api/models.py +++ b/service/api/models.py @@ -8,8 +8,9 @@ class User(db.Model): __tablename__ = 'users' - id = db.Column(db.Integer, primary_key=True) + id = db.Column(db.String(64), primary_key=True) username = db.Column(db.String(32), index=True) + email = db.Column(db.String(64)) password_hash = db.Column(db.Text) def hash_password(self, password): From 6ccb2252c426da7641a7a03b5ab8ea7bd89f65de Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Sat, 9 May 2020 16:35:41 +0530 Subject: [PATCH 03/13] Added oAuth generic implementation --- service/api/__init__.py | 7 ++-- service/api/oauth.py | 72 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 service/api/oauth.py diff --git a/service/api/__init__.py b/service/api/__init__.py index bf14761..f4b09cd 100644 --- a/service/api/__init__.py +++ b/service/api/__init__.py @@ -21,16 +21,19 @@ def create_app(): accesslogger.info("Loaded: Configuration of Stage") elif environ.get('ENV') == 'TESTING': app.config.from_object('config.TestConfig') + app.config.from_object('config.oAuthConfig') accesslogger.info("Loaded: Configuration of Testing") else: app.config.from_object('config.DevelopmentConfig') + app.config.from_object('config.oAuthConfig') accesslogger.info("Loaded: configuration of Development") db.init_app(app) with app.app_context(): - from . import routes # Import routes - db.create_all() # Create database tables for our data models + from . import routes_auth + from . import routes_oauth + db.create_all() return app diff --git a/service/api/oauth.py b/service/api/oauth.py new file mode 100644 index 0000000..a04c038 --- /dev/null +++ b/service/api/oauth.py @@ -0,0 +1,72 @@ +import json + +from rauth import OAuth2Service +from flask import current_app, url_for, request, redirect, session + +class OAuthSignIn(object): + providers = None + + def __init__(self, provider_name): + self.provider_name = provider_name + credential = current_app.config['OAUTH_CREDENTIALS'][provider_name] + self.consumer_id = credential['id'] + self.consumer_secret = credential['secret'] + + def authorize(self): + pass + + def callback(self): + pass + + def get_callback_url(self): + return url_for('oauth_callback', provider=self.provider_name, _external=True) + + @classmethod + def load_provider(self): + if self.providers is None: + self.providers = {} + for provider_class in self.__subclasses__(): + provider = provider_class() + self.providers[provider.provider_name] = provider + + @classmethod + def get_provider(self, provider_name): + self.load_provider() + return self.providers[provider_name] + +class FacebookSignIn(OAuthSignIn): + def __init__(self): + super(FacebookSignIn, self).__init__('facebook') + self.service = OAuth2Service( + name = 'facebook', + client_id = self.consumer_id, + client_secret = self.consumer_secret, + authorize_url = 'https://graph.facebook.com/oauth/authorize', + access_token_url = 'https://graph.facebook.com/oauth/access_token', + base_url = 'https://graph.facebook.com/' + ) + + def authorize(self): + return redirect(self.service.get_authorize_url( + scope = 'email', + response_type = 'code', + redirect_uri = self.get_callback_url() + )) + + def callback(self): + def decode_json(payload): + return json.loads(payload.decode('utf-8')) + + if 'code' not in request.args: + return None,None,None + oauth_session = self.service.get_auth_session( + data = {'code': request.args['code'], + 'grant_type': 'authorization_code', + 'redirect_uri': self.get_callback_url()}, + decoder = decode_json + ) + + me = oauth_session.get('me?fields=id,email').json() + print(me) + + return ('facebook$' + me['id'], me.get('email').split('@')[0], me.get('email')) From 4f582a16dfd3fd25438af5d00297cee4c2c655de Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Sat, 9 May 2020 16:36:08 +0530 Subject: [PATCH 04/13] Integrated facebook oAuth --- service/api/{routes.py => routes_auth.py} | 0 service/api/routes_oauth.py | 47 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) rename service/api/{routes.py => routes_auth.py} (100%) create mode 100644 service/api/routes_oauth.py diff --git a/service/api/routes.py b/service/api/routes_auth.py similarity index 100% rename from service/api/routes.py rename to service/api/routes_auth.py diff --git a/service/api/routes_oauth.py b/service/api/routes_oauth.py new file mode 100644 index 0000000..39c5038 --- /dev/null +++ b/service/api/routes_oauth.py @@ -0,0 +1,47 @@ +from flask import current_app as app +from flask import redirect, jsonify, request +from .oauth import OAuthSignIn +from .models import db, User +from flask_login import current_user, login_user +from .log import accesslogger + +@app.route('/oauth/') +def index(): + response = dict() + response["info"]="Basic oAuth API" + response["developer"]="Jalaz Kumar" + print(OAuthSignIn.providers) + response['providers']=str(OAuthSignIn.providers) + accesslogger.info("Accessed: oAuth API Introduction") + return (jsonify(response), 200) + +@app.route('/oauth/authorize/') +def oauth_authorize(provider): + oauth = OAuthSignIn.get_provider(provider) + return oauth.authorize() + +@app.route('/oauth/callback/') +def oauth_callback(provider): + oauth = OAuthSignIn.get_provider(provider) + id, username, email = oauth.callback() + if id is None: + return redirect('/oauth/failure/'+str(provider), 302) + + user = User.query.filter_by(id=id).first() + if not user: + user = User(id=id, username=username, email=email) + try: + db.session.add(user) + db.session.commit() + except: + db.session.rollback() + return redirect('/oauth/failure/'+str(provider), 302) + return redirect('/oauth/success/'+str(provider), 302) + +@app.route('/oauth/failure/') +def oauth_fail(provider): + return (jsonify({"message":"oAuth Failed"}), 503) + +@app.route('/oauth/success/') +def oauth_success(provider): + return (jsonify({"message":"oAuth Success"}), 200) From 314bd182660eedbc521319d577b7674e959353be Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Sat, 9 May 2020 16:38:18 +0530 Subject: [PATCH 05/13] Regenerate requirements.txt for oAuth packages --- requirements.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/requirements.txt b/requirements.txt index 18c43f1..90d43e9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,19 @@ +certifi==2020.4.5.1 +chardet==3.0.4 click==6.7 Flask==1.1.2 Flask-HTTPAuth==3.3.0 +Flask-Login==0.5.0 Flask-SQLAlchemy==2.4.1 gunicorn==19.9.0 +idna==2.9 itsdangerous==1.1.0 Jinja2==2.11.2 MarkupSafe==1.1.1 passlib==1.7.2 psycopg2-binary==2.8.5 +rauth==0.7.3 +requests==2.23.0 SQLAlchemy==1.3.16 +urllib3==1.25.9 Werkzeug==1.0.1 From 6650508c053ef38b6f80469b17256069988694f2 Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Sat, 9 May 2020 18:13:53 +0530 Subject: [PATCH 06/13] Unified bash file for running api for stage and dev --- service/start-dev.sh | 4 ---- service/start-stage.sh | 5 ----- service/start.sh | 10 ++++++++++ 3 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 service/start-dev.sh delete mode 100644 service/start-stage.sh create mode 100644 service/start.sh diff --git a/service/start-dev.sh b/service/start-dev.sh deleted file mode 100644 index 1afa6aa..0000000 --- a/service/start-dev.sh +++ /dev/null @@ -1,4 +0,0 @@ -source venv/bin/activate -export FLASK_ENV=development -source ./api.env -python app.py diff --git a/service/start-stage.sh b/service/start-stage.sh deleted file mode 100644 index 27b413e..0000000 --- a/service/start-stage.sh +++ /dev/null @@ -1,5 +0,0 @@ -source venv/bin/activate -export FLASK_ENV=stage -source ./api.env -export ENV='STAGE' -python app.py diff --git a/service/start.sh b/service/start.sh new file mode 100644 index 0000000..a3a94b8 --- /dev/null +++ b/service/start.sh @@ -0,0 +1,10 @@ +source venv/bin/activate +source ./api.env + +if [ "$1" == "--stage" -o "$1" == "-s" ]; then + export ENV='STAGE'; export FLASK_ENV=stage +else + export ENV='DEVELOPMENT'; export export FLASK_ENV=development +fi + +python app.py From b8d57f43146962c8057db2457811a6a5599f3345 Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Sat, 9 May 2020 18:29:25 +0530 Subject: [PATCH 07/13] Update helper-guide.md --- helper-guide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helper-guide.md b/helper-guide.md index 996cca7..9d2b622 100644 --- a/helper-guide.md +++ b/helper-guide.md @@ -11,7 +11,7 @@ `export SECRET_KEY=''` `export DEVELOPMENT_DATABASE_URL='sqlite:///auth.db'` `export ENV='DEVELOPMENT'` - + Run on dev environment using `bash start-dev.sh` + + Run on dev environment using `bash start.sh --dev` ## Running on Stage Environment @@ -24,7 +24,7 @@ - Close postgres console using `\q` + Add the following line to the file **api.env** `export STAGE_DATABASE_URL='postgresql+psycopg2://:@localhost/'` -+ Run on stage environment using `bash start-stage.sh` ++ Run on stage environment using `bash start.sh --stage` ## Running on Production Environment + Install Heroku CLI on machine using `curl https://cli-assets.heroku.com/install-ubuntu.sh | sh` and verify using `heroku --version` @@ -47,7 +47,7 @@ `export TESTING_DATABASE_URL='sqlite:///:memory:'` + Run tests on dev environment using `bash run-tests.sh` + Signup to Travis CI using GitHub and toggle the button to ON for Auth-API from `https://travis-ci.org/github/jaykay12/Auth-API` -+ Add the following entries in `Environment Variables` of Travis CI ++ Add the following entries in `Environment Variables` of Travis CI `ENV = 'TESTING'` `SECRET_KEY = Date: Sun, 10 May 2020 21:43:43 +0530 Subject: [PATCH 08/13] Added API documentations for Auth --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b45e09..0a18baf 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,7 @@ Authentication API based on Flask-SQLAlchemy [![Build Status](https://travis-ci.org/jaykay12/Auth-API.svg?branch=master)](https://travis-ci.org/jaykay12/Auth-API) -![Heroku](http://heroku-badge.herokuapp.com/?app=auth-api-flask&root=/api) +![Heroku](http://heroku-badge.herokuapp.com/?app=auth-api-flask&root=/api) + + +API Documentation: https://documenter.getpostman.com/view/8735978/SzmZcg5S?version=latest From c5ed46665f4f5322cea1ea7b1e7235b4fdd02295 Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Tue, 12 May 2020 03:03:17 +0530 Subject: [PATCH 09/13] Integrated Twitter oAuth --- service/api/oauth.py | 60 +++++++++++++++++++++++++++++-------- service/api/routes_oauth.py | 9 +++--- service/config.py | 6 +++- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/service/api/oauth.py b/service/api/oauth.py index a04c038..41e1ada 100644 --- a/service/api/oauth.py +++ b/service/api/oauth.py @@ -1,6 +1,6 @@ import json -from rauth import OAuth2Service +from rauth import OAuth1Service, OAuth2Service from flask import current_app, url_for, request, redirect, session class OAuthSignIn(object): @@ -47,11 +47,12 @@ def __init__(self): ) def authorize(self): - return redirect(self.service.get_authorize_url( - scope = 'email', - response_type = 'code', - redirect_uri = self.get_callback_url() - )) + params = { + 'scope': 'email', + 'response_type': 'code', + 'redirect_uri': self.get_callback_url() + } + return redirect(self.service.get_authorize_url(**params)) def callback(self): def decode_json(payload): @@ -59,14 +60,47 @@ def decode_json(payload): if 'code' not in request.args: return None,None,None - oauth_session = self.service.get_auth_session( - data = {'code': request.args['code'], - 'grant_type': 'authorization_code', - 'redirect_uri': self.get_callback_url()}, - decoder = decode_json + data = { + 'code': request.args['code'], + 'grant_type': 'authorization_code', + 'redirect_uri': self.get_callback_url() + } + oauth_session = self.service.get_auth_session(data = data, decoder = decode_json) + me = oauth_session.get('me?fields=id,email').json() + + return ('facebook$' + me['id'], me['email'].split('@')[0], me['email']) + +class TwitterSignIn(OAuthSignIn): + def __init__(self): + super(TwitterSignIn, self).__init__('twitter') + self.service = OAuth1Service( + name = 'twitter', + consumer_key=self.consumer_id, + consumer_secret=self.consumer_secret, + request_token_url='https://api.twitter.com/oauth/request_token', + authorize_url = 'https://api.twitter.com/oauth/authorize', + access_token_url = 'https://api.twitter.com/oauth/access_token', + base_url = 'https://api.twitter.com/1.1/' ) - me = oauth_session.get('me?fields=id,email').json() + def authorize(self): + params = { + 'oauth_callback': self.get_callback_url() + } + request_token = self.service.get_request_token(params = params) + + session['request_token'] = request_token + return redirect(self.service.get_authorize_url(request_token[0])) + + def callback(self): + request_token = session['request_token'] + if 'oauth_verifier' not in request.args: + return None, None, None + oauth_session = self.service.get_auth_session(request_token[0],request_token[1], + data={'oauth_verifier': request.args['oauth_verifier']} + ) + + me = oauth_session.get('account/verify_credentials.json').json() print(me) - return ('facebook$' + me['id'], me.get('email').split('@')[0], me.get('email')) + return ('twitter$' + str(me['id']), me['screen_name'], None) diff --git a/service/api/routes_oauth.py b/service/api/routes_oauth.py index 39c5038..cc772b1 100644 --- a/service/api/routes_oauth.py +++ b/service/api/routes_oauth.py @@ -1,5 +1,5 @@ from flask import current_app as app -from flask import redirect, jsonify, request +from flask import redirect, jsonify, request, flash from .oauth import OAuthSignIn from .models import db, User from flask_login import current_user, login_user @@ -10,7 +10,6 @@ def index(): response = dict() response["info"]="Basic oAuth API" response["developer"]="Jalaz Kumar" - print(OAuthSignIn.providers) response['providers']=str(OAuthSignIn.providers) accesslogger.info("Accessed: oAuth API Introduction") return (jsonify(response), 200) @@ -39,9 +38,11 @@ def oauth_callback(provider): return redirect('/oauth/success/'+str(provider), 302) @app.route('/oauth/failure/') -def oauth_fail(provider): - return (jsonify({"message":"oAuth Failed"}), 503) +def oauth_failure(provider): + flash("oAuth Failed") + return (jsonify({"message":"DB Error / Not Authorized"}), 503) @app.route('/oauth/success/') def oauth_success(provider): + flash("oAuth Success") return (jsonify({"message":"oAuth Success"}), 200) diff --git a/service/config.py b/service/config.py index 4f3e7ec..92d76a4 100644 --- a/service/config.py +++ b/service/config.py @@ -34,5 +34,9 @@ class oAuthConfig(object): "facebook": { "id": environ.get("FACEBOOK_APP_ID"), "secret": environ.get("FACEBOOK_APP_SECRET") - } + }, + "twitter": { + "id": environ.get("TWITTER_API_KEY"), + "secret": environ.get("TWITTER_API_SECRET") + } } From d462c282022605e71cc656bda95a517eabf1010b Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Tue, 12 May 2020 03:37:54 +0530 Subject: [PATCH 10/13] Integrated GitHub oAuth --- service/api/oauth.py | 33 +++++++++++++++++++++++++++++++++ service/config.py | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/service/api/oauth.py b/service/api/oauth.py index 41e1ada..53f9436 100644 --- a/service/api/oauth.py +++ b/service/api/oauth.py @@ -104,3 +104,36 @@ def callback(self): print(me) return ('twitter$' + str(me['id']), me['screen_name'], None) + +class GithubSignIn(OAuthSignIn): + def __init__(self): + super(GithubSignIn, self).__init__('github') + self.service = OAuth2Service( + name = 'github', + client_id = self.consumer_id, + client_secret = self.consumer_secret, + authorize_url = 'https://github.com/login/oauth/authorize', + access_token_url = 'https://github.com/login/oauth/access_token', + base_url = 'https://api.github.com/' + ) + + def authorize(self): + params = { + 'scope': 'user', + 'redirect_uri': self.get_callback_url() + } + return redirect(self.service.get_authorize_url(**params)) + + def callback(self): + + if 'code' not in request.args: + return None,None,None + data = { + 'code': request.args['code'], + 'grant_type': 'authorization_code', + 'redirect_uri': self.get_callback_url() + } + oauth_session = self.service.get_auth_session(data = data) + me = oauth_session.get('user').json() + + return ('github$' + str(me['id']), str(me['login']), str(me['email'])) diff --git a/service/config.py b/service/config.py index 92d76a4..31957c6 100644 --- a/service/config.py +++ b/service/config.py @@ -38,5 +38,9 @@ class oAuthConfig(object): "twitter": { "id": environ.get("TWITTER_API_KEY"), "secret": environ.get("TWITTER_API_SECRET") + }, + "github": { + "id": environ.get("GITHUB_CLIENT_ID"), + "secret": environ.get("GITHUB_CLIENT_SECRET") } } From 29b728c0b1f4711229f9552f04e6a5c6d177b28f Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Tue, 12 May 2020 11:32:36 +0530 Subject: [PATCH 11/13] Integrated Google oAuth --- service/api/oauth.py | 41 +++++++++++++++++++++++++++++++++++++++++ service/config.py | 4 ++++ 2 files changed, 45 insertions(+) diff --git a/service/api/oauth.py b/service/api/oauth.py index 53f9436..ed25cfe 100644 --- a/service/api/oauth.py +++ b/service/api/oauth.py @@ -137,3 +137,44 @@ def callback(self): me = oauth_session.get('user').json() return ('github$' + str(me['id']), str(me['login']), str(me['email'])) + +class GoogleSignIn(OAuthSignIn): + + # https://accounts.google.com/.well-known/openid-configuration + # https://developers.google.com/identity/protocols/oauth2/openid-connect + + def __init__(self): + super(GoogleSignIn, self).__init__('google') + self.service = OAuth2Service( + name = 'google', + client_id = self.consumer_id, + client_secret = self.consumer_secret, + authorize_url = 'https://accounts.google.com/o/oauth2/v2/auth', + access_token_url = 'https://oauth2.googleapis.com/token', + base_url = 'https://openidconnect.googleapis.com/v1/' + ) + + def authorize(self): + params = { + 'scope': 'openid profile email', + 'response_type': 'code', + 'redirect_uri': self.get_callback_url() + } + return redirect(self.service.get_authorize_url(**params)) + + def callback(self): + + def decode_json(payload): + return json.loads(payload.decode('utf-8')) + + if 'code' not in request.args: + return None,None,None + data = { + 'code': request.args['code'], + 'grant_type': 'authorization_code', + 'redirect_uri': self.get_callback_url() + } + oauth_session = self.service.get_auth_session(data = data, decoder = decode_json) + me = oauth_session.get('userinfo').json() + + return ('google$' + str(me['sub']), str(me['name']), str(me['email'])) diff --git a/service/config.py b/service/config.py index 31957c6..6f16edd 100644 --- a/service/config.py +++ b/service/config.py @@ -42,5 +42,9 @@ class oAuthConfig(object): "github": { "id": environ.get("GITHUB_CLIENT_ID"), "secret": environ.get("GITHUB_CLIENT_SECRET") + }, + "google": { + "id": environ.get("GOOGLE_CLIENT_ID"), + "secret": environ.get("GOOGLE_CLIENT_SECRET") } } From 601795862bcbd26945392e94afe6cd8a23c3705c Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Tue, 12 May 2020 12:51:07 +0530 Subject: [PATCH 12/13] Integrated LinkedIn oAuth --- service/api/oauth.py | 46 ++++++++++++++++++++++++++++++++++++++++++++ service/config.py | 4 ++++ 2 files changed, 50 insertions(+) diff --git a/service/api/oauth.py b/service/api/oauth.py index ed25cfe..a865d61 100644 --- a/service/api/oauth.py +++ b/service/api/oauth.py @@ -178,3 +178,49 @@ def decode_json(payload): me = oauth_session.get('userinfo').json() return ('google$' + str(me['sub']), str(me['name']), str(me['email'])) + +class LinkedInSignIn(OAuthSignIn): + + # https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow + # https://docs.microsoft.com/en-gb/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin + + def __init__(self): + super(LinkedInSignIn, self).__init__('linkedin') + self.service = OAuth2Service( + name = 'linkedin', + client_id = self.consumer_id, + client_secret = self.consumer_secret, + authorize_url = 'https://www.linkedin.com/oauth/v2/authorization', + access_token_url = 'https://www.linkedin.com/oauth/v2/accessToken', + base_url = 'https://api.linkedin.com/v2/' + ) + + def authorize(self): + params = { + 'scope': 'r_liteprofile r_emailaddress', + 'response_type': 'code', + 'redirect_uri': self.get_callback_url() + } + return redirect(self.service.get_authorize_url(**params)) + + def callback(self): + + def decode_json(payload): + return json.loads(payload.decode('utf-8')) + + if 'code' not in request.args: + return None,None,None + data = { + 'code': request.args['code'], + 'grant_type': 'authorization_code', + 'redirect_uri': self.get_callback_url() + } + oauth_session = self.service.get_auth_session(data = data, decoder = decode_json) + me = oauth_session.get('me').json() + email = oauth_session.get('emailAddress?q=members&projection=(elements*(handle~))').json() + + return ( + 'linkedin$' + str(me['id']), + str(me['localizedFirstName'])+str(me['localizedLastName']), + str(email['elements'][0]['handle~']['emailAddress']) + ) diff --git a/service/config.py b/service/config.py index 6f16edd..4629507 100644 --- a/service/config.py +++ b/service/config.py @@ -46,5 +46,9 @@ class oAuthConfig(object): "google": { "id": environ.get("GOOGLE_CLIENT_ID"), "secret": environ.get("GOOGLE_CLIENT_SECRET") + }, + "linkedin": { + "id": environ.get("LINKEDIN_CLIENT_ID"), + "secret": environ.get("LINKEDIN_CLIENT_SECRET") } } From 1641ec554ac2cf7ca91efd16a8cf4d5fe5abf8a8 Mon Sep 17 00:00:00 2001 From: Jalaz Kumar Date: Tue, 12 May 2020 20:33:22 +0530 Subject: [PATCH 13/13] Made changes ready for deployment --- service/api/__init__.py | 3 +++ service/api/oauth.py | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/service/api/__init__.py b/service/api/__init__.py index f4b09cd..0a4a1af 100644 --- a/service/api/__init__.py +++ b/service/api/__init__.py @@ -15,9 +15,11 @@ def create_app(): """Loading configuratons.""" if environ.get('ENV') == 'PRODUCTION': app.config.from_object('config.ProductionConfig') + app.config.from_object('config.oAuthConfig') accesslogger.info("Loaded: Configuration of Production") elif environ.get('ENV') == 'STAGE': app.config.from_object('config.StageConfig') + app.config.from_object('config.oAuthConfig') accesslogger.info("Loaded: Configuration of Stage") elif environ.get('ENV') == 'TESTING': app.config.from_object('config.TestConfig') @@ -33,6 +35,7 @@ def create_app(): with app.app_context(): from . import routes_auth from . import routes_oauth + db.drop_all() db.create_all() return app diff --git a/service/api/oauth.py b/service/api/oauth.py index a865d61..805c26e 100644 --- a/service/api/oauth.py +++ b/service/api/oauth.py @@ -101,7 +101,6 @@ def callback(self): ) me = oauth_session.get('account/verify_credentials.json').json() - print(me) return ('twitter$' + str(me['id']), me['screen_name'], None)