Firebase Auth and Facebook Login for Gaming

1,018 views
Skip to first unread message

Alex Ferrier

unread,
Oct 6, 2020, 9:46:16 AM10/6/20
to fireba...@googlegroups.com
Has anybody switched from Facebook Login to the new Facebook Login for Gaming and determined that it is then possible to then call Firebase Auth using an access token from the gaming graph API (at which point the facebook graph API won't be available so if Firebase.Auth.FacebookAuthProvider.GetCredential() calls the regular graph API we're stuck. 

We'd love to try using the new Facebook Gaming Graph API, but not enough to lose firebase in the process! 

Firebase.Auth.FacebookAuthProvider.GetCredential(accessToken);
auth
.SignInWithCredentialAsync(credential).ContinueWith(task => {

Kato Richardson

unread,
Oct 6, 2020, 1:56:31 PM10/6/20
to Firebase Google Group
Alex, 

Great to meet you! I don't know of anyone on the Firebase team who has tested this yet, but it seems very fast (and free) to try. Let us know if you have any issues.

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CAPQOqHiWh-dURqNa5rATHJaA2%3D-%2BbzwFCb6FTkuk9xgaOyDEOw%40mail.gmail.com.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

al...@nanuinteractive.com

unread,
Oct 16, 2020, 6:33:15 AM10/16/20
to Firebase Google Group
Based on testing, this does not currently work. Unity 2019.4.11, Firebase 6.15.2 from UPM.

We have updated one of our development apps to use the gaming graph. Login to facebook (using Facebook APIs) works correctly, and returns an access token of the form "GG|{tokenString}". Attempting to pass this token to SignInWithCredentialAsync() results in: 

     ---> (Inner Exception #0) Firebase.FirebaseException: The supplied auth credential is malformed or has expired.<---

     We can confirm that that token is for the gaming graph API (by logging the Facebook AccessToken's GraphDomain) , however, when we attempt to log in to Firebase using that token, SignInWithCredentialAsync() throws an exception , the inner of which is:

 "---> (Inner Exception #0) Firebase.FirebaseException: The supplied auth credential is malformed or has expired.<---"

Interestingly, Credential.IsValid() returns true. 

We are as certain we've got this test right as it's possible to be when most of the opportunities for error are mostly app configuration dashboards rather than the 10 lines of fairly well tested code (which we use with the regular FB Graph in multiple apps).

Relevant code: 

Debug.Log($"Getting credential from access token {AccessToken.CurrentAccessToken.TokenString}");
Firebase.Auth.Credential credential = Firebase.Auth.FacebookAuthProvider.GetCredential(AccessToken.CurrentAccessToken.TokenString);
Debug.Log($"Credential has provider {credential.Provider} : IsValid {credential.IsValid()}" + credential.ToString());
var authTask = auth.SignInWithCredentialAsync(credential);

Debug.Log("Android debugging with printf is fun.");

try
{
    var authUser = await authTask;
    Debug.Log($"Firebase auth sign in task completed. IsCompleted:{authTask.IsCompleted} IsCanceled:{authTask.IsCanceled}. UserID {authUser.UserId} Provider: {authUser.ProviderId}");
}
catch (System.Exception ex)
{
...


Results in debug output: 

Getting credential from access token GG|360413575143503|TSMeEBNI3HGY55Try83yfGizvDM 
Credential has provider facebook.com : IsValid True
---> (Inner Exception #0) Firebase.FirebaseException: The supplied auth credential is malformed or has expired.<---

Kato Richardson

unread,
Oct 16, 2020, 9:15:46 AM10/16/20
to Firebase Google Group
Thanks Alex. Appreciate you sharing the results back here.

A couple things:
  • It would be good to file a bug so the Unity team can have a look.
  • Assuming the token provides a user id of some sort, you could sign your own Firebase tokens to make this work.

Reply all
Reply to author
Forward
0 new messages