I used the auth(token, new Firebase.AuthListener()) function of firebase to authentication and access data, and I found that it sometimes spend long time(more than 5 minutes) to finished authentication. But this situation does not happened few month ago.
The Firebase library I downloaded from https://developer.nest.com/documentation/cloud/firebase-client-libraries , so my firebase library version is 1.1.1. Had anyone happen this kind of situation?
I had try to use authWithCustomToken(...) to replace the auth(...), but it not work. How do I used this function to authentication in nest?
And I found that the firebase added SSL to their protocol, is it the reson that caused above situation?
I download a firebase.js from
https://www.firebase.com/blog/2012-07-27-firebase-now-supports-ssl.html , but I don't know how to use this file
to create a *.crt or *.cer file, does anyone can help me?
/******************************* Update ***********************************/
The following are sample code as follow:
access_token I already get from nest via http request,
String Access_Token_URL = "https://api.home.nest.com/oauth2/access_token";
URL u = new URL(Access_Token_URL);
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
String cmd = "code="+pincode+"&client_id=" + Client_ID + "&client_secret="+ Client_secret +"&grant_type=authorization_code";
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
wr.writeBytes(cmd);
wr.flush();
wr.close(); // flush and close
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = reader.readLine()) != null){
//do something
}
reader.close();
JSONObject stock_data = new JSONObject(line);
access_token = stock_data.getString("access_token"); //access_token="c.W6o3HEpUe3a..........";
and I use the access_token in auth() function,
String DataBase_URL = "https://developer-api.nest.com";
Firebase myDataBase = new Firebase(DataBase_URL);
myDataBase.auth(access_token, new Firebase.AuthListener(){
@Override
public void onAuthError(FirebaseError arg0) {
// TODO Auto-generated method stub
Log.i(TAG, "AuthErro: " + arg0.getMessage());
//to do something...
}
@Override
public void onAuthRevoked(FirebaseError arg0) {
// TODO Auto-generated method stub
Log.i(TAG, "AuthRevoked: " + arg0.getMessage());
//to do something...
}
@Override
public void onAuthSuccess(Object arg0) {
// TODO Auto-generated method stub
Log.i(TAG, "AuthSuccess " + arg0.toString());
//to do something...
}
});
It spends more than 5 minutes to got the AuthSuccess message, is the behavior correct? If not, how should I modify my code?