Setup your own openhab-cloud (myopenhab) server/instance

Finally got the oauth part working with IFTTT. For the benefit of the rest, here are the steps I followed:

oauth2 setup for openhab-cloud

  1. From IFTTT API Tab select Authentication from left menu

  2. Select “My API has users with non-expiring OAuth2 access tokens” option

  3. Client ID: ifttt

  4. Client Secret: Type in any combination of long string of your choice

  5. Authorization URL: https://YOUR_DOMAIN/oauth2/authorize

  6. Token URL: https://YOUR_DOMAIN/oauth2/token

  7. Redirect URL: Log in - IFTTT

  8. Save

Now, we need to add IFTT token information in to mongo db.

  1. Log in to your openhab cloud server
  2. Change the directory to your openhab-cloud installation folder
    cd /opt/openhab-cloud/
  3. Create addoauth.js using Pedro Garcia’s script over here
    sudo nano addoauth.js
    paste the script content
    press ctrl+x and Y
  4. run the script
    sudo node addoauth.js ifttt ifttt <that long string you typed in IFTTT as Client Secret>

Run connection test from IFTTT to see if everything works as expected!
Note: You have to update config.json to include IFTTT Channel Key and test token as below:

  1. Edit config.json file
    sudo nano /opt/openhab-cloud/config.json

  2. Update the iftttChannelKey and the iftttTestToken as below

    “ifttt” : {
    “iftttChannelKey” : “Service key from IFTTT API tab - General section”,
    “iftttTestToken” : “See below”
    },

To obtain your iftttTestToken,

  1. Register a test user at your openhab cloud instance.
  2. Then enter those user credentials at the “Demo account login” section of the IFTTT API tab - Authentication section
  3. Run a connection test by clicking on the “Begin Test” button located at the “Connection Test” section of the API tab
  4. Click “Allow” when prompted to authorize IFTTT accessing your openhab-cloud
  5. Once test complete, Copy the “AccessToken” from the BODY of the RESPONSE of “Request Access Token” section. This becomes your iftttTestToken for the above config.jason update

Ah! one last point, don’t forget to Enjoy! :wink:

1 Like