Homey Authorization

I’ve been doing a lot of research and testing for a couple of days now and decided to come here to ask instead since I, to be honest, have absolutely no idea how to do this. I’ve been able to code for quite some time now but I decided to try to connect to homey using node.js. I’ve been following tutorials, on different sites but I can’t get it to work. My problem is trying to connect to homey. My current code looks like this:

const AthomCloudAPI = require('homey-api/lib/AthomCloudAPI');

async function myhome(){

// Create a Cloud API instance
const cloudApi = new AthomCloudAPI({
  clientId: 'MyId',
  clientSecret: 'MySecret',
});

// Get the logged in user
const user = await cloudApi.getAuthenticatedUser();

// Get the first Homey of the logged in user
const homeyApi = await user.getFirstHomey();

// Create a session on this Homey
const homey = await homey.authenticate();

}

myhome();

The error I’m getting is:

APIError: The access token was not found

I understand that I need to authenticate but that’s the part I’m having problems with. How should I do this?

Did you get it working?

I’ve used the old athom-api earlier, and had that working, but I am struggling with the homey-api now that athom-api is deprecated. I tried following the example from the documentation without any success yet.

I’m hosting my app on localhost as stated as the callback url in the example. When I click login I’m routed to athoms login page and when I log in with my username and password I am redirected back to my app and a code is added in the url, but I’m still not logged in it seems. :melting_face: