I am integrating Notion’s OAuth 2.0 authentication in Python using the Notion SDK and need to retrieve the redirected URL after user login and consent.
Expected Behavior: I want to automate the retrieval of the final redirected URL containing the code parameter after the user logs in and grants permissions. The goal is to extract the authorization code from the redirected URL and use it to obtain an access token.
What is the best way to programatically capture the redirected URL after user authentication and page permission in Python for an OAuth flow that requires interaction?
What I’ve Tried: Using requests.head(url, allow_redirects=True), but it doesn't work because the OAuth flow requires user interaction.
Tutorial I Followed . But in tutorial he has manually pasted the redirect_url , I am trying to automate the same thing but I don't know how to do it
-
Are you using a frontend framework or just django?Taha Boud– Taha Boud2025年02月20日 18:19:23 +00:00Commented Feb 20, 2025 at 18:19
-
I am using flask and I am not using any frontend framework, I am using the redirected_url_code to generate access token so that I can use it for my etl pipelinesShrishvesh Reddy– Shrishvesh Reddy2025年02月20日 18:24:10 +00:00Commented Feb 20, 2025 at 18:24
-
I would advise to provide some code for us to review, maybe the view function code?Taha Boud– Taha Boud2025年02月20日 18:48:49 +00:00Commented Feb 20, 2025 at 18:48
-
2You need to create a view function to handle the redirect url, for example if the redirect url redirects to the home page, in the function that renders the home page you will get access to query params ie authorization code in you caseTaha Boud– Taha Boud2025年02月20日 19:00:21 +00:00Commented Feb 20, 2025 at 19:00
-
if you follow some tutorial then you should add this in question (not in comments) - and more people will see to, so more people may help.,furas– furas2025年02月22日 16:06:50 +00:00Commented Feb 22, 2025 at 16:06