diff --git a/app.py b/app.py index 510b9be..fa6044c 100644 --- a/app.py +++ b/app.py @@ -3,7 +3,7 @@ import requests from authlib.integrations.base_client import OAuthError 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 @@ -32,10 +32,14 @@ oauth.register( @app.route("/api") def api(): - if 'accessToken' in request.cookies: + response = '' + if 'access_token' in request.cookies: access_token = request.cookies['access_token'] - print(access_token) - return make_response(redirect('http://localhost:5002/api?callbackUrl=http%3A%2F%2Flocalhost%3A5001')) + response = requests.get('http://localhost:5002/api?callbackUrl=http%3A%2F%2Flocalhost%3A5001', headers={'Authorization': f'Bearer {access_token}'}) + 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") def auth():