Open sachinjain024 opened 7 years ago
@sachinjain024 Hi! Have you found how to use firebase authentification in content script?
@maximtop No I could not find a proper solution to this. Instead what I did is the following:-
Have a look at this POC. I also used the above approach and it worked fine for me.
Currently, I am using the same in extension Requestly for authentication purpose and all other firebase interactions. You can check this out on https://www.requestly.in/rules after installing the extension and try to create and share a rule.
@sachinjain024 Thank you! I already came to message passing too. But I use chrome api for this purpose https://developer.chrome.com/apps/messaging
@maximtop You can use chrome apis to communicate between different script types supported in chrome extension but if you are using firebase at page level, you can not use chrome apis. In which particular script type, you are using firebase ?
@sachinjain024 If i get you, I use message passing to send message from content script to background script, and use response to print some data from firebase db on my site for authenticated user.
@maximtop Gotcha! But how are you authenticating the user in background script ?
User authenticates in extension on the options page. After that I import firebase instance in background script and check there if user is authenticated. Sorry I can't show you code because it is in an private gitlab repository. If you are interested in realization I can make an simple example to show you, later.
@maximtop Thanks for sharing this. No code is not required! I get the idea. Can you just tell me how did you import firebase instance in background from options page. Because localstorage is shared among options page and background so if user is logged into options page, you can detect it in background ?
@sachinjain024 Yes I think it works that way. Actually I created files with firebase, initialized firebase and after that exported it. Then I import it in option.js or background.js.
Browser: Chrome and Firefox Browser version: Firefox v52 and Chrome v58 Operating system: MaxOS Operating system version: v10.12.5
What steps will reproduce the problem:
What is the expected result? User should be logged in. Similar behaviour works well in Firebase v1 but faced this issue when trying to upgrade to v4.
What happens instead of that? User is taken to google signin screen and then he comes back to original site. Now when we check for current login status of user, it says user is not logged in.
Please provide any other information below, and attach a screenshot if possible. I have asked similar question here: https://stackoverflow.com/questions/44858133/using-authentication-inside-firebase-as-content-script-in-chrome-extension
Screenshots