alexander-albers / tripkit

Swift library for querying data from public transport providers.
MIT License
81 stars 8 forks source link

Can't add Api Keys #78

Closed victorlobe closed 1 year ago

victorlobe commented 1 year ago

Its not possible to add Api keys for DB anywhere.

alexander-albers commented 1 year ago

You can initialize the DB provider as follows:

let provider = DbProvider(
      apiAuthorization: [
            "type": "AID",
            "aid": ""
      ],
      requestVerification: AbstractHafasClientInterfaceProvider.RequestVerification.checksum(salt: "")
)

You can find the required struct format for the respective provider here: https://github.com/alexander-albers/tripkit/blob/main/Sources/TripKit/Resources/secrets.json.template For running the tests, you need to copy secrets.json.template to secrets.json and fill out the necessary keys.

victorlobe commented 1 year ago

Thank you very much for your quick response. I got a „client Id“ and a „client secret (api key)“, I pasted the secret key to the aid line but I don’t work. which keys do I have to add at which line?

alexander-albers commented 1 year ago

I'm not sure if we are talking about the same API. What endpoint are you trying to reach?

Edit: maybe to add, the client id is currently hardcoded in DbProider.swift. You could try to override it after initializing and setting RequestVerification to .none, but I don't know if that will work for you.

victorlobe commented 1 year ago

I am trying to reach the DB API, I got the following data:

![Uploading 4DE7502B-4BB5-4D2C-892C-9922F729BF99.jpeg…]()

victorlobe commented 1 year ago

BA4550C7-98A0-4C9D-BF7F-B14654E3D48A

alexander-albers commented 1 year ago

Unfortunately, this API is not supported by TripKit. You need to obtain a different key similar to the one the official DB Navigator app uses.

You can have a look at this project: https://github.com/public-transport/transport-apis

victorlobe commented 1 year ago

Ah ok, now I understand. Thank you very much! And keep up the good work :)