OAuth2 Token Generation on OpenHabCloud


I have my own openhab cloud setup. Instead of giving out username/password to 3rd party, I prefer to give them oAuth token since a openHAB Cloud can also act as an authorization server for oAuth2. I understand that we have to add in some entries in mongo via CLI, but I’m not sure how to associate those entries to specific account without going through the code. If someone has any associated link or info, please update. Thanks

We don’t add these a lot, so i always have to look at the code to remember . There are two mongo collections you need to modify. The first is to add a oauth scope, this is the collection oauth2scopes, and should look something like this:

	"_id" : ObjectId("..."),
	"name" : "alexa",
	"description" : "Access to my.openHAB specific API for Amazon Alexa"

The second collection is oauth2clients, this hold all the oauth details

	"_id" : ObjectId("..."),
	"name" : "Alexa",
	"description" : "Alexa Voice Control",
	"homeUrl" : "https://alexa.amazon.com",
	"icon" : "alexa.png",
	"clientId" : "some-client-id",
	"clientSecret" : "some-client-secret"

This uses passportjs if you are trying to troubleshoot, and just fyi debugging oauth can be a pain depending on the other party you are integrating with, so good luck, but i may not have any other help for you :frowning: