Google & Facebook OAuth without firebase
Hello, I am trying to make authentication system with google oauth. But as firebase is not free to use after certain request, that's why i want to do it by implementing the endpoint which i do in my react application. For this case i am using a package named
@react-oauth/google
But this is not working properly. I got some error like
Can anyone help me how to fix it? Or is there any blog or documentation for implement google and facebook oauth?12 Replies
@Asif Did you try to adjust the
content_security_policy
rules for the extension in package.json ?@Lionel Yeah. I have tried this. But this doesn't work for me.
I have implemented google oauth by calling the endpoint direct in my background. Like this:
This is just the basic code which is responsible for oauth
@Asif Which browser are you using?
There is a bug in some browsers that use Chromium, like Brave, where it fails when encoding the URL for the OAuth, so it fails with that error.
When I moved to Chrome specifically it worked.
If you still have a problem I will explain to you what I did for Google OAuth :)
@McJezus I am using chrome. Can you share what you did?
Sure thing. I am using this in the popup directly and not in the background:
@McJezus is the
handleOAuthLogin
function in your content ui? and can you show me your OAuthLogin?No it is in my popup file.
The OAuthLogin is a simple rtk mutation that calls a back-end route. It looks like this:
This can be exchanged for any function that makes a request to your back-end. It sends the token we received from the login to the back so it can exchange it for an access token.
@McJezus has reached level 1. GG!
@McJezus got it. thanks. i will try this approach
@Asif has reached level 3. GG!
Gave +1 Rep to @McJezus (current:
#26
- 1
)@Asif I'm actually wrong in my explanation.
The getAuthToken returns an OAuth2 token which is also cached by the identity API. This is given in the jsdoc for the function: