1

This is my first SO post, so forgive any mistakes please! I am also new to Java, and I am trying to use Firebase in Java to control my Nest thermostat. I have received an Authorization Code, which I traded for an accessToken. However, I cannot figure out how to authenticate using the Firebase Java library. The method is

public void authWithOAuthToken(String provider, String token, Firebase.AuthResultHandler handler)`. 

However, I can't figure out what the provider argument is supposed to be. I have tried google,Google,Nest,nest, custom, anonymous ; all to no avail.

I have the handler set up so that it prints out a success message or error message depending on which method gets called, but it isn't printing out either of these!

I'm not even sure if the provider is the reason why I'm not getting a response.

Attached is a snippet of the code and output.

System.out.println("OKAY IM HERE");
Firebase firebase = new Firebase("wss://developer-api.nest.com");
Firebase.AuthResultHandler handler = new Firebase.AuthResultHandler()
{
    public void onAuthenticated(AuthData authData)
    {
        System.out.println("Success! AuthData: " + authData);
    }

    public void onAuthenticationError(FirebaseError firebaseError)
    {
        System.out.println("Error! " + firebaseError);
    }
};
System.out.println("NOW IM HERE!");
//I'm hitting here
firebase.authWithOAuthToken("anonymous",accessToken,handler);
System.out.println("MAMA WE MADE IT");
//not hitting here

This is what the output is:

OKAY IM HERE
NOW IM HERE!

EDIT:

I have changed the method to:

    public void authWithCustomToken(String token, Firebase.AuthResultHandler handler)

and now I am getting the current output:

OKAY IM HERE
NOW IM HERE!
MAMA WE MADE IT

However, neither the onAuthenticated nor the onAuthenticationError methods are printing...

Jovan
  • 11
  • 2

1 Answers1

0

I realized that I actually have a firewall that is blocking the connection and causing a timeout. That fixes it!

Jovan
  • 11
  • 2