bureus / MMM-Vasttrafik-PublicTransport

Initial commit
9 stars 6 forks source link

location ID #9

Closed ZachariasHultman closed 4 years ago

ZachariasHultman commented 4 years ago

Hi!

I cant find the correct location ID at västrtrafik.

I want to get all departures from Regnbågsgatan and can't get that to work. The module is showing but i get error when running the code.

such as: generateAccessToken failed =StausCodeError: 401 - "{\"error\":\"invalid_client\",\"error_description\":\"Oauth application is not in active state.\"}".

I have followed all your steps and followed "Reseplaneraren v2".

What can i do now to fix this?

bureus commented 4 years ago

Hi @ZachariasHultman ,

401 means that your authorization token is wrong. Seems like something has happen on your application. Can you ensure that your client id and secret is correct and that your application is live?

You can find your secret and id on developer portal at västtrafik (https://developer.vasttrafik.se/portal/#/applications)

Here is all ids for Regnbågsgatan: <?xml version="1.0" encoding="UTF-8"?>

bureus commented 4 years ago

`<?xml version="1.0" encoding="UTF-8"?>

`
bureus commented 4 years ago

Also please ensure you have a subscription for your application: https://developer.vasttrafik.se/portal/#/subscriptions

bureus commented 4 years ago

Can you also please verify that you have an access token visible on: https://developer.vasttrafik.se/portal/#/api/Reseplaneraren/v2/landerss

image

ZachariasHultman commented 4 years ago

I have an access token visable at Reseplaneraren v2, similar as your picture shows. I think i might have problem with my application. I'm doing this on a raspberry pie and couldn't get "GET https://api.vasttrafik.se/bin/rest.exe/v2/location.name?input=centralstationen HTTP/1.1 Authorization: Bearer [access_token]" to work in the terminal. Maybe it has something to do with that. I have tripple checked my appKey and appSecret and they are correct.

What more exactily do you meen with that my application is live?

bureus commented 4 years ago

Okej, i guess it might be so that you are doing something wrong when converting your client id and secret to authorization header manually. Can you call the location endpoint from developer portal? (see screen below). If that works then you just need to setup apps config.

In order to run it locally you need to create a basic auth from your client id and secret. Have you followed the steps here? https://developer.vasttrafik.se/portal/#/guides/oauth2.

So what you can do, is to set your config to: { module: 'MMM-Vasttrafik-PublicTransport', position: 'bottom_left', header: "Västtrafik", config: { stopIds: ["9021014005465000"], //Regnbågsgatan appKey: "REPLACEWITHYOURCLIENTID", appSecret: "REPLACEWITHYOURCLIENTSECRET", debug: false, sortBy: "track", refreshRate: "20000", trafficSituations: false, board: { destination: { maxPxWidth: 200 } } } }

image

ZachariasHultman commented 4 years ago

Alright. I proparly have problem with oauth. I cant get "POST" and "GET" to work proparly in the terminal. Will do some more reserach about this.

thanks for your help

bureus commented 4 years ago

No worries good luck :) Will close the issue, please feel free to reopen if you cant solve it.