I'm trying to implement Discord authentication in my React app, using Firebase. I stumbled upon this answer which suggests calling a Firebase function which redirects to the Discord auth flow (where you need to click 'Authorize').
I'd like for this to behave the same as the Firebase sign in with Google flow. So like this:
- user clicks a button that says 'Sign in with Discord'
- a popup opens where Discord asks to Authorize
- user authorizes by clicking the button on the popup
- the popup closes and the user is now logged in
How can I trigger a Firebase function (probably a HTTPS function?) from my React app, so it will open a popup? I've tried Firebase's HttpsCallable in the frontend to trigger a Firebase function that calls response.redirect(discordAuthRedirectLink), but this only triggers the function (it doesn't open a popup or redirect).
CodePudding user response:
You can't open a popup in the client directly from the server (that would be a major security concern), but your Cloud Function can return a value that your client-side code then interprets and opens a popup in response.
Having to perform multiple calls (to multiple services) during a sign-in flow such as this is quite common, so I wouldn't worry too much about that early on.