pocketbase / js-sdk

PocketBase JavaScript SDK

Home Page:https://www.npmjs.com/package/pocketbase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Safari OAuth2 Popup Won't work.

wenogk opened this issue · comments

What?

Safari blocks popups that don't come from a click handler. Even if we use the authWithOAuth2 method on a click event, since the function is async, it is blocked and the user has to manually allow the popups in order to complete authentication which is very bad for UX and actually completely blocked in iPhone Safari so effectively impossible to login with OAuth?

How to reproduce?

Simply call a button with an onclick listener that calls the method like await pb.collection('users').authWithOAuth2({ provider: 'google' }); on Safari on a Mac or iPhone and the popup will be blocked. On iPhone the popup doesn't appear at all.

With JS SDK v0.17+ we eagerly open the popup before the async event to workaround this, but I don't have Safari, nor iPhone to test it.

In any case, the issue is not with the JS SDK. If you already use JS SDK v0.17+, then you can check pocketbase/pocketbase#2429.