I'm struggling to authenticate in HERE plugin. I'm using windows 10 with Qt 5.9.1 Mingw 32bit and my app is almost all written in c++. The only part Where I use QML is about the map. I want to use the HERE plugin, but I am a newbie with QtLocation and plugins, and I really can't understand what I need to do to authenticate in HERE. I tried to follow the guide on the HERE site but I really can't understand.
I know from qt that the code I must use to athenticate on HERE is the following:
Plugin {
name: "here"
PluginParameter { name: "here.app_id"; value: "myapp" }
PluginParameter { name: "here.token"; value: "abcdefg12345" }
}
So I need here.app_id and here.token.
I created an account on the HERE site and I created a project using REST. So now I have my APP ID parameter but I really don't understand how to get the TOKEN value to put in the second line. First of all for my specific case I need to create an api key or an OAuth 2.0?
I tried to follow what is written in this link using Postman and at the end I got a really long tokoen that I copied and put in the "here.token" parameter but when I run the application it gives me Invalid here.token and it does not display the map.
Can somebody give me any hint on how to correctly get the token value? Or can somebody point me to some links? Is there a different way to login using an api key for example instead of the token?
---------------- UPDATE ---------------------------------------
After some time I had to return on this problem that I never solved: the situation right now is that I manage to get the token through postman but it's always invalid. Right now I'm using Qt 5.15.2 and MinGw 64 bit.
I'm using the minimal_map example modified to add the here.app_id and here.token parameter.
main.qml
import QtQuick 2.15
import QtQuick.Window 2.15
import QtLocation 5.6
import QtPositioning 5.6
Window {
width: Qt.platform.os == "android" ? Screen.width : 512
height: Qt.platform.os == "android" ? Screen.height : 512
visible: true
Plugin {
id: mapPlugin
name: "here" // "mapboxgl", "esri", ...
// specify plugin parameters if necessary
parameters: [
PluginParameter {
name: "here.app_id"
value: "xxxxx"
},
PluginParameter {
name: "here.token"
value: "yyyyyy"
}]
}
Map {
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(59.91, 10.75) // Oslo
zoomLevel: 14
}
}
the problem is that when I run the app the output is the following:
Invalid here.token
3 , "Qt Location requires app_id and token parameters.\nPlease register at https://developer.here.com/ to get your personal application credentials."
To get the token I've done the following:
- I registered myself at developer.here site with a Freemium plan and I created a project.
- I created a REST API and an OAuth 2.0 (JSON Web Tokens) as follows (I saved the credentials.properties files that I used in the 3. step):
- I download Postman, I created an account and I followed the instruction from the answer to this question.
I received response in a json format like this:
a
- I went in my minimal_map example and I set as app_id (instead of "xxxxx") the APP ID value displayed inside the first image I posted and as here.token (instead of the "yyyyyy") the acces_token received in the JSON response from POSTMAN.
- I tried to clean the project, delete the build folder but nothing changed, the answer is always:
Invalid here.token
3 , "Qt Location requires app_id and token parameters.\nPlease register at https://developer.here.com/ to get your personal application credentials."
What am I missing to get a token to display the here plugin in Qt?