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();



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:

Update for anyone having similar issues:
The following method call failed for me: cloudApi.hasAuthorizationToken().
When the callback was invoked it didn’t apply “code=1233789” at the end of my url. I used vue-router and had the following url: localhost:80/#/ but after the callback this was localhost:80/code=1233789#/ which did not work. I parsed it myself instead of using cloudApi.hasAuthorizationToken and passed in the correct token, then everything worked just fine.

I’m using the WebApI only with plain http (and official client ID).
But shouldn’t the callback be http://localhost:80 and the call shold be http://localhost:80?code=12345 as URL parameter?

Yeah, callback url is set to http://localhost:80, but when I run the web application (with vue router) the url shows http://localhost:80/#/ in my browser, so after the authorization it then shows http://localhost:80/code=12345#/

Haven’t tried changing the callback url to http://localhost:80/#/ to see if that would have solved my issue. I’ll try a couple of things next time I get time to play around with it

I tried again with the login screen in browser console and I get this callback:


So it seems that the slash is added after the domain and then directly the URL parameter as there is no file name in the URL. Perhaps your router is interpreting the parameter without file prefix in a wrong way?

At first glance it seems like it’s probably the webhashistory causing it?