grzegorz914 / homebridge-xbox-tv

Homebridge plugin for Microsoft Game Console, publish as independent external platform accessory.
MIT License
164 stars 15 forks source link

how do i get web api token #179

Closed lunarnaut3 closed 1 year ago

lunarnaut3 commented 1 year ago

i dont know how to get a web api token

grzegorz914 commented 1 year ago

Use authorization manager and read the displayed step by step instruction

anthonysnyder commented 1 year ago

@lunarnaut3 I am having the same issue. I cannot get the Authorization Manager to do anything.

@grzegorz914 Firstly, thanks for this, I love the idea of this integration for automation purposes.

I am getting the following alert in the logs. 7/6/2023, 12:24:46 PM] [homebridge-xbox-tv] Loaded homebridge-xbox-tv v2.8.22 child bridge successfully [7/6/2023, 12:24:47 PM] Homebridge v1.6.1 (HAP v0.11.1) (homebridge-xbox-tv) is running on port 49672. Error: Unhandled error. ('no oauth token found. Use authorization manager first.') at new NodeError (node:internal/errors:400:5) at AUTHENTICATION.emit (node:events:502:17) at /homebridge/node_modules/homebridge-xbox-tv/src/webApi/authentication.js:212:26 at new Promise (<anonymous>) at AUTHENTICATION.checkAuthorization (/homebridge/node_modules/homebridge-xbox-tv/src/webApi/authentication.js:204:16) at new AUTHENTICATION (/homebridge/node_modules/homebridge-xbox-tv/src/webApi/authentication.js:26:14) at new XBOXWEBAPI (/homebridge/node_modules/homebridge-xbox-tv/src/webApi/xboxwebapi.js:43:31) at new XboxDevice (/homebridge/node_modules/homebridge-xbox-tv/src/xboxdevice.js:258:31) at HomebridgeAPI.<anonymous> (/homebridge/node_modules/homebridge-xbox-tv/index.js:31:24) at HomebridgeAPI.emit (node:events:513:28)

when I add the device, I am then prompted to restart HomeBridge, so I do so.

Then I navigate back to the Settings for the Plugin, and click Start Auth. I get a spinning gear, but nothing else happens. This is within multiple browsers and devices. Any advice is GREATLY appreciated

grzegorz914 commented 1 year ago

First you need config plugin before you start authorization manager. Important are: name, host and xboxLiveId then start authorization manager. Post video how do you do?

tothemoonsands commented 1 year ago

I also am getting an error - I was previously authorized before these last few updates, but after updating I was getting an alert saying I need to reauthorize. When clicking on Clear Web API Token OR "Start Authorization" (after manually clearing the token in the JSON config, I get this error:

` [homebridge-xbox-tv] node:internal/errors:490 ErrorCaptureStackTrace(err); ^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('no oauth token found. Use authorization manager first.') at new NodeError (node:internal/errors:399:5) at AUTHENTICATION.emit (node:events:502:17) at /usr/local/lib/node_modules/homebridge-xbox-tv/src/webApi/authentication.js:212:26 at new Promise () at AUTHENTICATION.checkAuthorization (/usr/local/lib/node_modules/homebridge-xbox-tv/src/webApi/authentication.js:204:16) at new AUTHENTICATION (/usr/local/lib/node_modules/homebridge-xbox-tv/src/webApi/authentication.js:26:14) at PluginUiServer.startAuthorization (/usr/local/lib/node_modules/homebridge-xbox-tv/homebridge-ui/server.js:36:28) at PluginUiServer.processRequest (/usr/local/lib/node_modules/homebridge-xbox-tv/node_modules/@homebridge/plugin-ui-utils/dist/server.js:75:63) at process. (/usr/local/lib/node_modules/homebridge-xbox-tv/node_modules/@homebridge/plugin-ui-utils/dist/server.js:44:26) at process.emit (node:events:513:28) { code: 'ERR_UNHANDLED_ERROR', context: 'no oauth token found. Use authorization manager first.' }

Node.js v18.16.0`

tothemoonsands commented 1 year ago

Rollback to 2.8.18 solved this error, authorization works and I can get my power on/off functioning again.

grzegorz914 commented 1 year ago

try latest beta please, should be fixed now and let me know

tothemoonsands commented 1 year ago

Beta is working well for me! Thank you so much @grzegorz914 for your work on this project. It's so much better than HDMI-CEC, and enables some very cool automation potential.

anthonysnyder commented 1 year ago

@grzegorz914 I am sure this is user error, but it is still not working for me, even after updating. Here is a link to a screen recording that I just took: https://drive.google.com/file/d/1p2TkXntUDZfm4Uian9WBf0SJ_b3XBSkM/view?usp=drive_link

Thank you so much

grzegorz914 commented 1 year ago

what a error is displayed

anthonysnyder commented 1 year ago

    ErrorCaptureStackTrace(err);
    ^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('no oauth token found. Use authorization manager first.')
    at new NodeError (node:internal/errors:400:5)
    at AUTHENTICATION.emit (node:events:502:17)
    at /homebridge/node_modules/homebridge-xbox-tv/src/webApi/authentication.js:207:26
    at new Promise (<anonymous>)
    at AUTHENTICATION.checkAuthorization (/homebridge/node_modules/homebridge-xbox-tv/src/webApi/authentication.js:199:16)
    at new AUTHENTICATION (/homebridge/node_modules/homebridge-xbox-tv/src/webApi/authentication.js:26:14)
    at PluginUiServer.startAuthorization (/homebridge/node_modules/homebridge-xbox-tv/homebridge-ui/server.js:36:28)
    at PluginUiServer.processRequest (/homebridge/node_modules/homebridge-xbox-tv/node_modules/@homebridge/plugin-ui-utils/dist/server.js:75:63)
    at process.<anonymous> (/homebridge/node_modules/homebridge-xbox-tv/node_modules/@homebridge/plugin-ui-utils/dist/server.js:44:26)
    at process.emit (node:events:513:28) {
  code: 'ERR_UNHANDLED_ERROR',
  context: 'no oauth token found. Use authorization manager first.'
}
[7/7/2023, 10:01:27 AM] [Homebridge UI] [homebridge-xbox-tv] Node.js v18.13.0
[7/7/2023, 10:01:27 AM] [Homebridge UI] [homebridge-xbox-tv] Child process ended```
tothemoonsands commented 1 year ago

@grzegorz914 I am sure this is user error, but it is still not working for me, even after updating. Here is a link to a screen recording that I just took: https://drive.google.com/file/d/1p2TkXntUDZfm4Uian9WBf0SJ_b3XBSkM/view?usp=drive_link

Thank you so much

This isn't a direct fix but for me I rolled back to 2.8.18 and then I was able to re-authenticate, after which I updated to the latest version and it still worked.

anthonysnyder commented 1 year ago

trying this now

anthonysnyder commented 1 year ago

@tothemoonsands That worked! 🥳 Thanks for that.

grzegorz914 commented 1 year ago

@anthonysnyder try latest beta, chould be fixed now