1

I am new to programming for Nest and I am confused about how to get the authorization from Nest via firebase API.

I want to write an App in Android to access device information. I had already registered an account at Nest and created a client from the web interface. I got the Authorization URL at the client page and I used the chrome extension to create 2 virtual devices.

From https://developer.nest.com/documentation/authorization-overview, I know I need to use PIN based method so I am using the following code:

Firebase ref = new Firebase("https://home.nest.com/login/oauth2?client_id=CLIENT_ID&state=STATE");
Log.i(TAG, "getParams " + ref.getParams());

When I log this information, I got the following log:

getParams {}

Can anyone help me obtain authorization from Nest via firebase API?


UPDATE

I have studied the website RIT gave but there are some things I am still confused about.

My client page has the following information:

Client ID:  b4bf4721-2***-4***-a***-c1a*********
Client secret: S578in************
Authorization URL: https://home.nest.com/login/oauth2?client_id=b4bf4721-2***-4***-a***-c1a*********&state=STATE
Access Token URL: https://api.home.nest.com/oauth2/access_token?code=AUTHORIZATION_CODE&client_id=b4bf4721-2***-4***-a***-c1a*********&client_secret=S578in************&grant_type=authorization_code

When I use the following code:

Firebase ref = new Firebase(Authorization URL);

I expect it will return the PIN code, but it doesn't.

Also, from https://developer.nest.com/documentation/how-to-auth, topic 3. Exchange your authorization code for an access token has a command:

"POST https://api.home.nest.com/oauth2/access_token?code=STRING&client_id=STRING&client_secret=STRING&grant_type=authorization_code"

Does anyone knows if there is any firebase API can achieve this command?

Luke Willis
  • 8,429
  • 4
  • 46
  • 79
WangKuo
  • 13
  • 4
  • I think there is something wrong in the url, you are using. Check these links, hope these will help you. http://stackoverflow.com/questions/24601798/acquiring-and-changing-basic-data-on-the-nest-thermostat & http://stackoverflow.com/questions/24615141/connecting-java-standalone-server-to-nest-cloud-via-firebase-api – VVB Jul 25 '14 at 07:36
  • The post to Authorization URL returns a page with Angular JS bindings, browser can evaluate and bindings however our code can't. If you analyze the browser traffic, you can see there is a GET request to https://home.nest.com/api/0.1/oauth2/clients/{YOUR_CLIENT_ID}?locale=en-US and the basic auth header. Now the key to get the basic auth header b.4###.Mu################ – PerlDev Oct 14 '16 at 17:33

1 Answers1

1

Authorization is done following the OAuth 2.0 protocol, once you have a token from that, you can use the Firebase API. The firebase protocol does not provide direct authorization.

Community
  • 1
  • 1
David W. Keith
  • 2,246
  • 17
  • 20