access token through Authorization bearer
This commit is contained in:
parent
7478dee246
commit
ea8100a764
12
app.py
12
app.py
@ -3,7 +3,7 @@ import requests
|
|||||||
from authlib.integrations.base_client import OAuthError
|
from authlib.integrations.base_client import OAuthError
|
||||||
from authlib.integrations.flask_client import OAuth
|
from authlib.integrations.flask_client import OAuth
|
||||||
|
|
||||||
from flask import Flask, request, redirect, session, render_template, url_for, make_response
|
from flask import Flask, request, redirect, Response, session, render_template, url_for, make_response
|
||||||
|
|
||||||
# TODO add client export json in project & git
|
# TODO add client export json in project & git
|
||||||
|
|
||||||
@ -32,10 +32,14 @@ oauth.register(
|
|||||||
|
|
||||||
@app.route("/api")
|
@app.route("/api")
|
||||||
def api():
|
def api():
|
||||||
if 'accessToken' in request.cookies:
|
response = ''
|
||||||
|
if 'access_token' in request.cookies:
|
||||||
access_token = request.cookies['access_token']
|
access_token = request.cookies['access_token']
|
||||||
print(access_token)
|
response = requests.get('http://localhost:5002/api?callbackUrl=http%3A%2F%2Flocalhost%3A5001', headers={'Authorization': f'Bearer {access_token}'})
|
||||||
return make_response(redirect('http://localhost:5002/api?callbackUrl=http%3A%2F%2Flocalhost%3A5001'))
|
else:
|
||||||
|
response = requests.get('http://localhost:5002/api?callbackUrl=http%3A%2F%2Flocalhost%3A5001')
|
||||||
|
return Response(response=response.text, status=response.status_code, headers=dict(response.headers))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/auth")
|
@app.route("/auth")
|
||||||
def auth():
|
def auth():
|
||||||
|
Loading…
Reference in New Issue
Block a user