'Is there a way to redirect twice?
So I hit a login route(python) from my frontend(react) that returns a auth_url to login using oauth. Then it needs to wait for the user to sign on and redirect back to frontend. Atm I can't figure out how to do both.
Either my frontend fetches the url, then window.location.replace(url), you sign on, then since the login route is only sending the url, there is no redirect back to frontend. Once logged on it just shows backend with a page showing auth_url
Or my frontend just makes the call to log on, and the backend redirects to auth_url without a way to redirect after completion to the frontend.
I can’t find any examples online of redirecting twice so it seems my logic is wrong. Is putting the url in a header the thing people do here?
My attempt:
async def test(url):
#redirect to oauth to sign in
await url
return redirect(url)
async def test2(testfinish):
# after oauth is complete, redirect to my frontend
await testfinish
return redirect('http://localhost:3000/')
@app.route("/login")
def login():
session["flow"] = _build_auth_code_flow(scopes=SCOPE)
auth_url=session["flow"]["auth_uri"]
return test2(test(auth_url))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|