Auth0 in react-native application not working for chrome extension

I am building a chrome-extension for one of my react-native applications. It uses auth0 for authentication, works perfectly on web, but not in chrome extension.

I am using MemoryRouter for managing routes for chrome extension.

Since auth0 is a third-party platform it needs to be handled in different way?

I found this https://github.com/auth0-community/auth0-chrome but this repo is depricated so I am not sure on proceeding with this.

Any suggestions will be helpful and let me know if I am missing something.

1 Like

Hi @kishor-tricon,

Welcome to the Auth0 Community Forum!

I have not seen a replacement for that repo. Could you tell us more about the problems you are running into? Also, how are you using react native with a chrome extension?

Thanks,
Dan

Thanks @dan.woda!

I am using expo tools for building the react-native application and using the bundled version I could build a chrome extension.

For the web version I have followed the Auth0 steps and added necessary callback urls in Auth0 account.

this.auth0.authorize({
      state: window.location.href,
      code_challenge: challenge,
      code_challenge_method: 'S256'
});

This will open the auth0 popup in web and redirect urls are handled properly.

But the above thing won’t work for chrome-extension as it doesn’t deal with urls. I need to do something similar as shown in above code if application is running as chrome extension.

The problems I faced after using auth0-chrome plugin

  1. Login popup opens in a separate window and upon successful login, app loads in the same popup not in chrome-extension.
  2. Login popup opens after 3-4 clicks and is inconsistent always.
    Throws the following error when popup fails to open

Uncaught (in promise) TypeError: Cannot read property ‘create’ of undefined

  1. So main issue which I am unable to understand is how do I pass the control back to the extension upon successful login?

I am new to this stuff and I tried my best to explain what’s happening. Please let me know if you need any specific details.

Thanks,
Kishor

@kishor-tricon,

Got it. I wouldn’t necessarily recommend using the auth0-chrome repro, since it is deprecated and has been for some time. You may be leaving your app open to some security issues there.

I can’t say I have enough familiarity with chrome extensions to provide a solution either. I will leave this topic open and maybe we can get some more eyes on it.

I know expo has caused some problems before, it may be worth checking this thread out if you haven’t already:

Sorry I don’t have a better answer for you!