Using Auth0 to authenticate within a Chrome Extension

Hi,

This topic is similar to:

However, the information in that topic seems to no longer apply, or at least the successes there are only half-documented and I cannot replicate their success.

I am trying to authenticate within a Chrome Extension, and I see two possible methods:

  1. Authenticate on the Extension Options page
  2. Authenticate on the Extension Popup

I have tried option 1, however the loginWithPopup() method fails at creating a new popup window, instead a new tab is opened with the internal address of about:blank#blocked.
(See similar GitHub issue: https://github.com/auth0/auth0-spa-js/issues/300)
loginWithRedirect() is not an option here as the Extension Options is within a Chrome modal window, and this method just causes it to error and loose all of it’s content.

With option 2, the loginWithPopup() method can actually successfully open a popup window to the login page, but I’m now struggling with the correct redirect and callback URL values to use. I have tried setting them to be the chrome://extensions/?id=extension-id-here URL, hoping I could catch the token there, but the popup gets stuck on a blank “Authorisation Response” page.

Should I be using some middle-man hosted webpage to redirect to and collect the token?
Has anyone got an actual functioning Auth0 flow within a Chrome Extension?

Appreciate any help.

Have you figured this out yet? I am having the same issue here.

Hey, yeah I have this working now, but I had to implement it without the use of the Auth0 SDK, just putting it all together manually.

I’ll update this thread with some samples this weekend.

1 Like

@gilhrpenner I put together a post: https://roberttolton.com/posts/implementing-auth0-authentication-into-a-chrome-extension

Let me know if there’s anything unclear.

2 Likes

@mirai-auth0 I will try your approach tomorrow but from quickly reading it I can see where I’ve been doing it wrong.
Thank you so much for this! Really thankful

1 Like

Thanks for sharing it Mirai with the rest of community!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.