How would I authenticate users with Discord's OAUTH Api (https://discordapp.com/developers/docs/topics/oauth2) for Firebase?
I'm new to this sort of thing, so I would really appreciate the help!
Here is my recommendation :
1.Build Firebase Cloud Function
2.Call the Firebase Cloud Function from the front end application
3.In the Cloud Function , re-direct to Discord and complete the oAuth flow
4.On completion of oAuth flow and once the Discord token is received back in the cloud function , mint a new token using Firebase Admin SDK. Add uid as one of the parameter while minting the token. This uid can be the user name or user id sent by Discord in their token response.
5.Once the Firebase token is minted, send back the token to the front end application.
6.From the app , again call the Firebase SDK to Sign-in to Firebase with SignInCustomToken sdk and send the Firebase token sent by Cloud Function
7.Above step will insert a user record in Firebase Authentication system, if not available already.
8.Use the Firebase id token and access token for all interactions with Firebase going forward.
Reference : Create Custom token using Firebase Admin SDK https://firebase.google.com/docs/auth/admin/create-custom-tokens
You can skip the step with regard to service account because the Firebase Cloud Function provides the necessary wrapper to generate custom token directly without a service account concept.
Thanks,
Dinakaran
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With