bureus / MMM-Vasttrafik-PublicTransport

Initial commit
9 stars 6 forks source link

StatusCode 401 #25

Open manshurtigh opened 1 year ago

manshurtigh commented 1 year ago

Hi!

It seems to me that I cannot connect to Västtrafik. I was wondering if anyone has seen this problem before? See logs belows.

[27.07.2023 17:55.31.923] [LOG]   5:55:31 PM MMM-Vasttrafik-PublicTransport: generateAccessToken failed =StatusCodeError: 401 - ""
[27.07.2023 17:55.31.932] [WARN]  Unhandled rejection ReferenceError: reject is not defined
    at /opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_helper.js:78:11
    at tryCatcher (/opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues [as _onImmediate] (/opt/magic_mirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:15:14)
    at process.processImmediate (node:internal/timers:476:21)

401 indicates that I have an authorization issue, but I can't figure out what's wrong. I've checked the APIs that the application is subscribed to. See below image.

2023-07-27 18_06_58-Västtrafik - Developer portal - My applications

I am using ClientID as "appKey" and Secret as "appSecret".

appKey: "yyyyyy",
appSecret: "xxxxxxxxxx",

Am I doing something wrong?

Xkhi commented 1 year ago

I had similar issues with this module, what I noticed is that it relies on v2 of Västtrafik's API, I made a fork to update it to v4 and merge some other forks to support multi-filtering. Feel free to check the other forks https://github.com/bureus/MMM-Vasttrafik-PublicTransport/network/members

manshurtigh commented 1 year ago

Yeah, I saw that this one relies on v2 as well and I thought it had something to do with that as well.

Thank you for creating a fork and updating it to v4. I actually started to use MMM-ResRobot instead in the mean time. I will try your fork.

manshurtigh commented 1 year ago

Your fork worked perfectly! Thank you so much @Xkhi.

I suggest that you actually put this up as a separate "version 2" or something similar on the 3rd module pages here on Github so more people can find this.

I leave this comment open so more people may find it since the authentication is a crucial part of the module to work. Again, thank you so much @Xkhi.

Xkhi commented 1 year ago

I thought of doing that, but it felt wrong... but now that you suggest it, I'll do it. Thanks for the encouragement.

manshurtigh commented 1 year ago

Do it! I don't think @bureus supports this module anymore.

manshurtigh commented 1 year ago

@Xkhi Could you add me on Discord? My name is snåm#8165. I have some more ideas for this module, if you are interested.

Xkhi commented 1 year ago

I don't use discord that much, but sure, we can discuss in private

Bagronk commented 10 months ago

Hi, I just thought I'd check with you. The only thing that shows up on my MagicMirror is the Västtrafik logo. What could be wrong? I setup a mirror in 2018 or something and that has worked until now when the SD-card in the Pi died, and I can't find the backup. So now I have a Linux Mint based Mirror. I got the API to the weather module to work but not this one.

Xkhi commented 10 months ago

this library is super outdated, I would recommend to use one of the forks that stem from it

Bagronk commented 10 months ago

Oh, I am. I was just a bit tired and commented here. I'm using your fork.

kallby86 commented 7 months ago

I also only get the Västtrafik Logo and i have updated to your fork? @Bagronk did you get it to work?

Bagronk commented 7 months ago

I got it working, and it is working. But I can't remember what I did. It does however give me errors in the terminal when running the mirror.

Are you using xkhi's fork?

Bagronk commented 7 months ago

Actually! Check the brackets one by one. I have a vague memory of something being off with the brackets.

kallby86 commented 7 months ago

Yes i am using xkhi's fork. Then i have alot of work to do, i am not a programmer either so i don't understand the brackets very well

kallby86 commented 7 months ago

[23.01.2024 00:03.58.287] [LOG] 00:03:58 MMM-Vasttrafik-PublicTransport: generateAccessToken failed =StatusCodeError: 401 - "{\"error_description\":\"Client Authentication failed.\",\"error\":\"invalid_client\"}" [23.01.2024 00:03.58.304] [WARN] Unhandled rejection ReferenceError: reject is not defined at /home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_helper.js:78:11 at tryCatcher (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:725:18) at _drainQueueStep (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:461:21)

Bagronk commented 7 months ago

I'm not that good at this either but it seems like the token and client doesn't work.

Have you gone to the developer site, created account and created application?

Den tis 23 jan. 2024 00:06kallby86 @.***> skrev:

[23.01.2024 00:03.58.287] [LOG] 00:03:58 MMM-Vasttrafik-PublicTransport: generateAccessToken failed =StatusCodeError: 401 - "{"error_description":"Client Authentication failed.","error":"invalid_client"}" [23.01.2024 00:03.58.304] [WARN] Unhandled rejection ReferenceError: reject is not defined at /home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_helper.js:78:11 at tryCatcher (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/promise.js:725:18) at _drainQueueStep (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/home/pi/MagicMirror/modules/MMM-Vasttrafik-PublicTransport/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:461:21)

— Reply to this email directly, view it on GitHub https://github.com/bureus/MMM-Vasttrafik-PublicTransport/issues/25#issuecomment-1904986817, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQT3AVOFEJUT22HTWAU5DGDYP3WFTAVCNFSM6AAAAAA22J7BVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBUHE4DMOBRG4 . You are receiving this because you were mentioned.Message ID: @.***>

Xkhi commented 7 months ago

Hi guys, I have enabled issues in my fork, you can go ahead and move the conversation there