Skip to content

Commit bf5eb07

Browse files
committed
Use JWT for payload
1 parent 0300504 commit bf5eb07

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ Thumbs.db
4444
# Environment #
4545
###############
4646
*.env
47+
venv/

app.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,16 @@ def auth_callback():
188188
@app.route('/bigcommerce/load')
189189
def load():
190190
# Decode and verify payload
191-
payload = flask.request.args['signed_payload']
192-
user_data = BigcommerceApi.oauth_verify_payload(payload, client_secret())
193-
if user_data is False:
191+
payload = flask.request.args['signed_payload_jwt']
192+
try:
193+
user_data = BigcommerceApi.oauth_verify_payload_jwt(payload, client_secret(), client_id())
194+
except Exception as e:
195+
print(e)
194196
return "Payload verification failed!", 401
195197

196198
bc_user_id = user_data['user']['id']
197199
email = user_data['user']['email']
198-
store_hash = user_data['store_hash']
200+
store_hash = user_data['sub'].split('stores/')[1]
199201

200202
# Lookup store
201203
store = Store.query.filter_by(store_hash=store_hash).first()

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Werkzeug==2.0.1
44
itsdangerous==2.0.1
55
requests==2.25.1
66
python-dotenv==0.17.1
7-
bigcommerce==0.22.0
7+
bigcommerce==0.22.2
88
gunicorn==20.1.0
99
psycopg2==2.8.6
1010
Flask-SQLAlchemy==2.5.1

0 commit comments

Comments
 (0)