OAuth inside PWA in iOS takes you out of PWA and in to Safari

I’ve created a service which relies on the user logging in with their Patreon account. If their pledge is > X they get access to exclusive content. This works. Yey! But when you add the site/app to your home screen on iOS and open it from the home screen this happens:

  1. The user hits the “Log in with Patreon” button
  2. If the user has the Patreon app installed, iOS opens this app for authentication. If not you’re sent to Safari.
  3. Either way you’re sent to Safari after login since the callback URL from Patreon is a web page.

Here’s a screen capture to illustrate the problem.

Is there a workaround with this? I’ve tried using popup screens for the OAuth to keep everything in the same site and closing it when authentication is finished, but the popup can’t be closed programmatically when it’s inside a PWA.

Thanks!

I believe there is a specific url in Android that you can use to get the user back to your app which can be used as a redirect uri. I suspect iOS should have one too. Try using such an url as a redirect uri.

Hi Hanserino. Just wondering if you found a solution to this, please? I’m having the same issue (only on iOS). Thanks. Shaun.

No, I didn’t find a solution to this. Let me know if you do!

This is late, but I did eventually find a way to get this to work for iOS. The downside is that you need a server that can store data (probably a database). The Patreon oauth URL has a state query param that it will pass back to you in the redirect. In the PWA, generate a UUID and include it with the state. After your server authenticates with Patreon’s auth code, store the UUID and auth data in the database. When the user returns back to the PWA, you can make a call to your server to retrieve that auth data and delete it from the database.