Get Your Credentials
All users of the HERE platform must obtain authentication and authorization credentials.
For the available authentication options, see the Identity & Access Management Developer Guide.
Note
Downloading the Data Client Library
To download the Data Client Library, you need repository credentials. To obtain your credentials, log in to the HERE platform and navigate to https://platform.here.com/profile/repository. Click Create credentials, and then download the settings.xml
file.
Credential Options
The snippets below demonstrate different ways of supplying your platform credentials to the Data Client Library.
When you initialize a new service client without supplying any credentials as arguments, the Data Client Library attempts to find your platform credentials using the default credential provider chain: a platform credentials file in the JVM classpath, the default location platform credentials download location (~/.here/credentials.properties
) and the Java system properties in that order.
Note
Billing tags and optional projects scope
The snippets below also demonstrate the use of HERE platform billing tags, which you can use in requests to the platform in order to later associate your requests with the invoicing for those requests.
A configuration property here.token.scope
/here-token-scope
is optional. It provides access to Project resources (catalogs, schemas, pipelines).
Set Your Credentials via the Application's Configuration File
This is the recommended approach.
Based on the values in the platform credentials, include the following parameters in your application.conf
file:
here.platform.data-client.request-signer {
billing-tag = "example_billing_tag"
credentials {
here-account {
here-token-endpoint-url = "https://account.api.here.com/oauth2/token"
here-client-id = "example-client-id"
here-access-key-id = "example-access-key-id"
here-access-key-secret = "example-access-key-secret"
here-token-scope = "example-token-scope [optional]"
}
}
}
here.platform.data-client.request-signer {
billing-tag = "example_billing_tag"
credentials {
here-token = "example-token"
}
}
Set Your Credentials in the Credentials File
The Data Client Library can read HERE access key and access secret data from the credentials.properties
file.
-
The client looks for a credentials.properties
file in the Java Virtual Machine (JVM) classpath.
-
A fallback location to find platform credentials is in ~/.here/credentials.properties
-
Alternatively, you can specify an alternate credentials file location in the application.conf
file.
here.platform.data-client.request-signer {
billing-tag = "example_billing_tag"
credentials {
file-path = "/path/credentials.properties"
}
}
Example of credentials properties file:
here.user.id = example-here-user-id
here.client.id = example-client-id
here.access.key.id = example-access-key-id
here.access.key.secret = example-access-key-secret
here.token.endpoint.url = https://account.api.here.com/oauth2/token
here.token.scope = hrn:here:authorization:::project/example-project
Note
Using previously generated tokens
Previously generated HERE tokens are not supported for the platform credentials file format.
Set Your Credentials via Java System Properties
To set your credentials via Java System Properties, define the following:
-Dhere.platform.data-client.request-signer.credentials.here-account.here-token-endpoint-url="https://account.api.here.com/oauth2/token"
-Dhere.platform.data-client.request-signer.credentials.here-account.here-client-id="example-client-id"
-Dhere.platform.data-client.request-signer.credentials.here-account.here-access-key-id="example-access-key-id"
-Dhere.platform.data-client.request-signer.credentials.here-account.here-access-key-secret="example-access-key-secret"
-Dhere.platform.data-client.request-signer.credentials.here-account.here-token-scope="example-token-scope [optional]"
-Dhere.platform.data-client.request-signer.credentials.here-token="example-token"
Set Your Credentials Programmatically
To set your HERE account programmatically, include the following in your project:
val exampleHrn = HRN(s"hrn:${DiscoveryService.env}:data:::demo-catalog")
val dataClient = DataClient()
val settings =
DataClient().defaultSettings
.withRequestSignerSettings(
HereAccountRequestSignerSettings(
hereClientId = "<here-account-client-id>",
hereAccessKeyId = "<here-account-access-key-id>",
hereAccessKeySecret = "<here-account-access-key-secret>",
hereTokenScope = Some("<here-token-scope [optional]>")
)
)
.withBillingTag("<billing-tag>")
dataClient.queryApi(exampleHrn, settings)
HRN exampleHrn = HRN.fromString("hrn:here:data:::demo-catalog");
DataClient dataClient = DataClient.get(myActorSystem);
Settings defaultSettings = dataClient.defaultSettings();
HereAccountRequestSignerSettings hereAccountRequestSignerSettings =
new HereAccountRequestSignerSettings.Builder()
.withHereClientId("<here-account-client-id>")
.withHereAccessKeyId("<here-account-access-key>")
.withHereAccessKeySecret("<here-account-access-secret>")
.withHereTokenScope("<here-token-scope [optional]>")
.withHereTokenEndpointUrl("<here-token-endpoint-url [optional]>")
.build();
Settings settings =
defaultSettings
.withRequestSignerSettings(hereAccountRequestSignerSettings)
.withBillingTag("<billing-tag>");
QueryApi queryApi = dataClient.queryApi(exampleHrn, settings);
To set your HERE token programmatically, include the following in your project:
val exampleHrn = HRN(s"hrn:${DiscoveryService.env}:data:::demo-catalog")
val dataClient = DataClient()
val settings =
DataClient().defaultSettings
.withRequestSignerSettings(
HereTokenRequestSignerSettings(
hereToken = "<here-token>"
)
)
.withBillingTag("<billing-tag>")
dataClient.queryApi(exampleHrn, settings)
HRN exampleHrn = HRN.fromString("hrn:here:data:::demo-catalog");
DataClient dataClient = DataClient.get(myActorSystem);
Settings defaultSettings = dataClient.defaultSettings();
RequestSignerSettings hereTokenRequestSignerSettings =
new HereTokenRequestSignerSettings.Builder().withHereToken("<here-token>").build();
Settings settings =
defaultSettings
.withRequestSignerSettings(hereTokenRequestSignerSettings)
.withBillingTag("<billing-tag>");
QueryApi queryApi = dataClient.queryApi(exampleHrn, settings);