gotelegram-botnotion-apitelegram-webhook

Is there a way to provide additional data to Notion's OAuth flow?


I am building a Telegram bot (webhook implemented) to interact with Notion API. I need to link Telegram and Notion users between each other.

My Authorization URL from Notion's integration page looks like this:

https://api.notion.com/v1/oauth/authorize?client_id=123&response_type=code&owner=user&redirect_uri=https://de86-171-5-224-214.ngrok-free.app/notion/oauth/callback

Take a look at redirect_uri query param. I need something like redirect_uri=https://de86-171-5-224-214.ngrok-free.app/notion/oauth/callback?extra_data=test

When I try to pass any extra params to redirect_uri, it does not affect at all. After redirect to my callback endpoint, Notion pass the same params code=123&state= without customization. Is there a way to do so? Or maybe some hacks?

I am using Golang to build a bot.

Thank you for your time in advance!


Solution

  • Actually, Notion does allow to set state query parameter. Also for me the problem was "?" symbol in the redirect_uri.

    Before fix:

    redirect_uri=https://de86-171-5-224-214.ngrok-free.app/notion/oauth/callback?extra_data=test
    

    After fix:

    redirect_uri=https://de86-171-5-224-214.ngrok-free.app/notion/oauth/callback&state=test