Using Mapbox Services requires setting a valid access token
JonasVautherin opened this issue · 5 comments
Running the example app with my Graphhopper token, I get the following exception:
com.mapbox.core.exceptions.ServicesException: Using Mapbox Services requires setting a valid access token.
As specified in the README, I set my API key in the config:
<string name="base_url" translatable="false">https://graphhopper.com/api/1/navigate/</string>
<string name="mapbox_access_token" translatable="false">MY_KEY</string>
I tried using my key in https://explorer.graphhopper.com/ and it works, so it seems like the token itself should be fine.
What could I be doing wrong? I am really just trying to run this example app.
+1. This app does not work out of the box. The mapbox service expects a key starting with "pk.", but the api key from graphhopper does not srart with 'pk.'. Did anyone even test this before pushing the code to github?
One way to make it work is, instead of putting GRAPHHOPPER_API_KEY
, put pk.GRAPHHOPPER_API_KEY
in developer_config.xml. eg:
<string name="mapbox_access_token" translatable="false">pk.XXXXXXX-YYYY-ZZZZ-1111-32783abdef5</string>
Oh you're right, it helps! Does that trick work for you in https://github.com/maplibre/maplibre-navigation-android? Doesn't work for me, not sure what changed between them.
@tarangill thanks for pointing this out! We should make it more clear in the documentation and or directly in the config.
@JonasVautherin this repository is a very recent fork of the maplibre example code, so it is relative unlikely that the same solution does not work there. What exactly did not work for you there? There are a few changes required to make GraphHopper routing working with maplibre (which this repo already did).
Oh, I was missing this:
this.user("gh")
this.profile("car")
And now it works 😊. Thanks a lot!