Frontify / frontify-authenticator

Authenticate to your Frontify instance from within any secure web app
MIT License
0 stars 1 forks source link

Authentication without window.open()? #2

Closed getflourish closed 6 months ago

getflourish commented 2 years ago

Hey! This looks like a super convenient helper!

I know this repository is built for specific purposes where it works great just like it is. But I’m in a context (WKWebView on macOS, Sketch) where window.open() is not available. I know how to do the auth flow myself, but it would be fantastic to use this library instead.

Is it possible to get direct access to the URL and skip the Popup flow (implement some polling myself)? So I’m mainly interested in the first part that includes the PKCE (Proof Key for Code Exchange).

Curious to hear if the library provides some intermediate access to the generated URL.

Cheers!

barisbikmaz commented 7 months ago

I have a similiar problem. I want to use the Frontify Finder in an Office Addin. But Office Addins does not support window.open. I can think of two solutions:

  1. A flow without a Popup where you can redirect to an authetication page that redirects back with the auth token.
  2. You can pass in your own implementation for Popup
jasonhieu1905 commented 6 months ago

The add-ins in the Office environment, such as Word, do not allow the use of window.open. I have included some screenshots below.

image The code that throws the error:

static openPopUp(e) {
            const t = window.open(
                'about:blank',
                e.title,
                `width=${e.width}, 
            height=${e.height}, 
            left=${e.left}, 
            top=${e.top}, 
            toolbar=no, menubar=no, 
            location=no, status=no, 
            directories=no, titlebar=no`,
            );
            if (!t)
                throw new s(
                    'ERR_AUTH_POPUP_BLOCKED',
                    'Popup is blocked. Make sure to enable popups.',
                );
            return t;
        }
floriangaechter commented 6 months ago

We're not planning on implementing an non-popup option. But you can work around the issue by implementing a code flow with PKCE as described here: https://github.com/aaronpk/pkce-vanilla-js.