Here is where I'm stuck on Firebase auth. Hopefully someone in the world will know?

I’m trying to get google and twitter login working on a project so I can authenticate with firebase:

    void LoginScene::loginWithGoogle() {
        this->logMessage("Signing in with Google ...");
        Credential google_credential =
                GoogleAuthProvider::GetCredential("");
        Auth* auth = Auth::GetAuth(firebase::App::GetInstance());
        _google_sign_in_future = auth->SignInWithCredential(google_credential);
    }

    void LoginScene::loginWithTwitter() {
        this->logMessage("Signing in with Twitter ...");
        Credential twitter_credential =
                FacebookAuthProvider::GetCredential("");

        Auth* auth = Auth::GetAuth(firebase::App::GetInstance());
        _twitter_sign_in_future = auth->SignInWithCredential(twitter_credential);
    }

This will NOT work because I don’t have the value to put into GetCredential when requesting a credential from the Auth providers. In the notes Firebase suggest running Java code:

https://firebase.google.com/docs/auth/cpp/twitter-login
https://firebase.google.com/docs/auth/cpp/google-signin

“Authenticate with Firebase
Follow Twitter sign-in instructions for Android and iOS to get an OAuth access token and an OAuth secret.
After a user successfully signs in, exchange the token and secret for a Firebase credential, and authenticate with Firebase using the Firebase credential:
…”

“Authenticate with Firebase
Follow instructions for Android and iOS to get an ID token for the Google sign in.
After a user successfully signs in, exchange the ID token for a Firebase credential, and authenticate with Firebase using the Firebase credential:
…”

But it’s at this point where I get really stuck? For example, that might be possible if I knew how to get back to Java…but what about iOS? If anyone can help/advise it would be great. I’m out of my depth with this one.

Thanks,
Katie

Without checking everything, but did you visit the cocos2d-x cpp samples on github?

For the Java/Android part, you can take a look in my runtime permission sample. In that sample, I call Java from cpp and also get data back.

This will help you at least half the way :wink:

Hi, thanks I did look at the cocos2d-x cpp samples but unfortunately they only cover username/password and anonymous login. You right about my needing to understand how to get into java and back out again. It looks like from the docs I would need to start an activity or a fragment. Do you know of any samples on how to do this or is that what your runtime permissions sample does?

Also I have just followed your example, it was very clear… I will try and complete the cycle.

1 Like

I completed this successfully on Android using JNI with callbacks and FragmentActivity classes in Java. Now I can successfully login to Firebase using both Twitter and Google OAuth tokens. The easiest way for Facebook was to use SDKBox. If anyone would like to know more let me know, I might write a blog post if that would help,