firebase - Facebook authentication invalid access_token error code 43
Hello there,
I am trying to use Facebook Authentication for Firebase and I reached the stage where an exception is thrown (most of the time) in the android device saying,
SignInWithCredentialAsync encountered an error: System.aggregateexception: ... Firebase.FirebaseException: An internal error has occurred. [ invalid access_token error code 43 ]
Like in the image! attached I found no similar problem, and I don't know where can I use the error code 43 to reach an answer
Specially it worked ONCE!!, without changing anything .. I don't know what should I do?
Firebase.Auth.Credential credential =
Firebase.Auth.FacebookAuthProvider.GetCredential(token.TokenString);
auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
if (task.IsCanceled)
{
playerAppManager.DebugData("SignInWithCredentialAsync was canceled.");
return;
}
if (task.IsFaulted)
{
playerAppManager.DebugData ("SignInWithCredentialAsync encountered an error: " + task.Exception.ToString());
return;
}
Firebase.Auth.FirebaseUser newUser = task.Result;
Debug.LogFormat("User signed in successfully: {0} ({1})",
newUser.DisplayName, newUser.UserId);
playerAppManager.DebugData(newUser.DisplayName +" -- "+ newUser.UserId);
});
i have the same problem with the unity facebook sdk. it tells me i have an invalid access token when i try to access the facebook api.let me know if you find a solution
Answer by Paulk33 · Aug 15, 2017 at 07:23 PM
hi. i was getting the same error with the facebook sdk. This may help you....
so i have this function init'ing my scripts and the facebook api: void Awake() {
FB.Init(OnFacebookInitialized);
if (!FB.IsInitialized)
{
// Initialize the Facebook SDK
FB.Init(InitCallback, OnHideUnity);
}
else
{
// Already initialized, signal an app activation App Event
FB.ActivateApp();
}
}
which in turn then calls this:
private void OnFacebookInitialized()
{
Debug.Log("Logging into Facebook...");
// Once Facebook SDK is initialized, if we are logged in, we log out to demonstrate the entire authentication cycle.
if (FB.IsLoggedIn)
FB.LogOut();
List<string> permissions = new List<string> { "public_profile", "user_friends", "email" };
// We invoke basic login procedure and pass in the callback to process the result
FB.LogInWithReadPermissions(permissions, authCallBack);
}
what my issue was my user was always logged in, thus my token expired. idk if this helps but i have been stuck on an invalid access token error for a while and tried to reference your code to see if could help. hope this helps!
Your answer
![](https://koobas.hobune.stream/wayback/20220612123202im_/https://answers.unity.com/themes/thub/images/avi.jpg)