1

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

asked Feb 20, 2025 at 18:12
6
  • Are you using a frontend framework or just django? Commented 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 pipelines Commented Feb 20, 2025 at 18:24
  • I would advise to provide some code for us to review, maybe the view function code? Commented Feb 20, 2025 at 18:48
  • 2
    You 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 case Commented 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., Commented Feb 22, 2025 at 16:06

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.