Integrating Notion API with mobile app: OAuth setup challenges

I’m working on a mobile app and want to use the Notion API. The tricky part is setting up OAuth because when I add a redirect URI, it automatically prepends https:// to it, which stops me from using a custom scheme like myapp://notion/oauth.

My plan is to launch the mobile browser for Notion login and have it redirect back to my app. However, this redirection doesn’t work as I expected without HTTPS. Has anyone figured out how to register a non-HTTPS URI for this purpose or found an alternative method for mobile apps?

Here’s a simple example of my current approach:

fun initiateOAuth() {
    val newScheme = "myapp://notion/oauth"
    // Notion adds https:// in front, which causes issues
    notionApi.setRedirectUri(newScheme)
    // Looking for a solution to bypass this automatic addition
}

I’ve been struggling with this for a while now. Any suggestions or advice would be greatly appreciated!

hey alex, i ran into similar issues. try using a url shortener like bit.ly to create an https redirect for your custom scheme. it might not be perfect, but it worked for me and was easier than reconfiguring stuff.

I’ve encountered a similar issue with the Notion API and found that setting up an intermediary web server simplified the process. In my experience, setting up a small server, for example using Express.js, to handle the OAuth callback was key. I registered the server’s URL as the redirect URI in Notion and then opened the Notion auth page in my mobile app via a WebView. When Notion redirected to my server, it forwarded the auth code back to the app via a deep link.

This method allowed me to use an HTTPS URL for Notion’s redirect while still receiving the auth code. Although it required extra configuration, the solution proved to be secure and reliable. Just be sure to secure the server and manage any connection issues that might arise.

Having worked with the Notion API recently, I can share a workaround that proved effective. Instead of directly using a custom scheme, consider implementing a universal link (iOS) or app link (Android). This approach allows you to register an HTTPS URL that Notion accepts, while still enabling your app to intercept the redirect.

First, set up a domain you control as your redirect URI in Notion’s OAuth settings. Then, configure your app to handle deep linking for that domain. When Notion redirects to your URL, the operating system will route it to your app if installed, or fall back to the browser if not.

This method maintains security standards and provides a seamless user experience. It does require some additional setup, including server-side configuration, but it’s a robust solution that adheres to modern mobile development best practices.