# Homey Authorization

**URL:** <https://community.homey.app/t/homey-authorization/57533>\
**Category:** Developers\
**Tags:** homey\
**Created:** [December 31, 2021, 9:33am UTC](https://community.homey.app/t/homey-authorization/57533 "2021-12-31T09:33:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![George\_Mandell](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/george_mandell/32/49589_2.png) [@George\_Mandell](https://community.homey.app/u/George_Mandell)\
**Post date:** [December 31, 2021, 9:33am UTC](https://community.homey.app/t/homey-authorization/57533/1 "2021-12-31T09:33:03Z")

</div>

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:

```auto
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![kjeet90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kjeet90/32/45190_2.png) [@kjeet90](https://community.homey.app/u/kjeet90)\
**Post date:** [July 21, 2022, 9:34pm UTC](https://community.homey.app/t/homey-authorization/57533/2 "2022-07-21T21:34:02Z")

</div>

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](https://athombv.github.io/node-homey-api/AthomCloudAPI.html) 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. 🫠

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.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [October 11, 2022, 6:06am UTC](https://community.homey.app/t/homey-authorization/57533/3 "2022-10-11T06:06:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kjeet90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kjeet90/32/45190_2.png) [@kjeet90](https://community.homey.app/u/kjeet90)\
**Post date:** [October 11, 2022, 6:34am UTC](https://community.homey.app/t/homey-authorization/57533/4 "2022-10-11T06:34:08Z")

</div>

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

Haven’t tried changing the callback url to [http://localhost:80/#/](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

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [October 11, 2022, 6:49am UTC](https://community.homey.app/t/homey-authorization/57533/5 "2022-10-11T06:49:40Z")

</div>

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

![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/8/b88862c92873d44f7ccb28eabacd5e2ba13b6a49.png)

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?

---

<div class="post-metadata">

**Author:** ![kjeet90](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kjeet90/32/45190_2.png) [@kjeet90](https://community.homey.app/u/kjeet90)\
**Post date:** [October 11, 2022, 10:09am UTC](https://community.homey.app/t/homey-authorization/57533/6 "2022-10-11T10:09:35Z")

</div>

At first glance it seems like it’s probably the [webhashistory](https://router.vuejs.org/api/index.html#createwebhashhistory) causing it?
