Search code examples
iosnest-api

Sign out Option in Nest API?


I am developing a iOS application using nest apis, I am able to sign in to my nest account by presenting the nest web view and able to get all the smoke and thermostats associated with that account.

When I'm signing in with different account, I'm getting the devices which were added to the previous account, not the devices added to the current account.

These are my questions:

  1. How to sign out from current user account?
  2. How to get devices from multiple nest accounts?

https://github.com/nestlabs/iOS-NestDK

Here I am able to login for the first time, I have written the code to re login from another nest account (by presenting the nest web view) but I'm getting the structure of previous (which is first account's structure) after login with another nest account.


Solution

  • You can find the info on Deauthentication and invalidating tokens in our docs here: https://developer.nest.com/documentation/cloud/deauthorization-overview/

    Make an HTTP DELETE call and replace <access_token> with the token you would like to invalidate. Here is an example in cURL.

    curl -v -X DELETE 
    "https://api.home.nest.com/oauth2/access_tokens/<access_token>"
    

    That will remove your connection with that token as well as invalidate so any other service using it will no longer have access.