Integration with Firebase - hippogamesunity/SimpleSignIn GitHub Wiki

DISCLAIMER

I'm not a developer of Firebase and can't provide support for it. Please refer to Firebase docs and consider this article as some experience sharing.

Apple

As Firebase requires that nonce should be hashed with SHA256 for further JWT validation, you can generate a random nonce and pass it to SignIn method as an optional parameter. It will be hashed, URL-endoded and passed to Apple with your authorization request.

More info: https://firebase.google.com/docs/auth/ios/apple

  1. Open your project in Firebase Console
  2. Navigate to Authentication
  3. Go to Sign-in method
  4. Select Apple from Sign-in providers (if not available, click "Add new provider" and add Apple)
  5. Specify the Identifier of the Services ID you created in the Services ID.
var appleAuth = new AppleAuth();
var nonce = Guid.NewGuid().ToString("N");
var tokenResponse = await appleAuth.GetTokenResponseAsync(nonce);
var credential = OAuthProvider.GetCredential("apple.com", tokenResponse.IdToken, nonce, tokenResponse.AccessToken);

// Usage example:
// FirebaseAuth.SignInAndRetrieveDataWithCredentialAsync(credential);
// FirebaseUser.LinkWithCredentialAsync(credential);

Google

  1. Open your project in Firebase Console
  2. Navigate to Authentication
  3. Go to Sign-in method
  4. Select Google from Sign-in providers (if not available, click "Add new provider" and add Google)
  5. Under "Safelist client IDs from external projects (optional)", add the client ID you created
var googleAuth = new GoogleAuth();
var tokenResponse = await googleAuth.GetTokenResponseAsync();
var credential = GoogleAuthProvider.GetCredential(tokenResponse.IdToken, tokenResponse.AccessToken);

// Usage example:
// FirebaseAuth.SignInAndRetrieveDataWithCredentialAsync(credential);
// FirebaseUser.LinkWithCredentialAsync(credential);

Other platforms

Please share your experience in our Discord channel.