Prerequisites

Before you can install HERE Location Services for Python, run its test-suite, or use the example notebooks to make sure you meet the following prerequisites:

  • A Python installation, 3.6+ recommended, with the pip command available to install dependencies.

  • In order to use Location services APIs, authentication is required.

    There are two ways to authenticate: * Authentication using an API key:

    • For API key-based authentication you will need a HERE developer account, freely available under HERE Developer Portal.

    • An API key from the HERE Developer Portal, in an environment variable named LS_API_KEY which you can set like this (with a valid value, of course):

      $ export LS_API_KEY="MY-LS-API-KEY"
      
    • OAuth token-based authentication:

      • For OAuth token authentication you will need an account on the HERE Platform. To get more details on the HERE Platform account please check our documentation Get a HERE account.

      Once you have the account follow the below steps to get credentials:

      The HERE platform generated app credentials should look similar to the example below:

      here.user.id = <example_here>
      here.client.id = <example_here>
      here.access.key.id = <example_here>
      here.access.key.secret = <example_here>
      here.token.endpoint.url = <example_here>
      

      You can provide your credentials using any of the following methods:

      • Default credentials

      Place the credentials file into

      For Linux/MacOS: $HOME/.here/credentials.properties

      For Windows: %USERPROFILE%.herecredentials.properties Code snippet to instantiate LS object:

      from here_location_services import LS
      
      # platform credentials will be picked from the default credentials file's location mentioned above
      # and api_key should not be set in env variable LS_API_KEY.
      ls = LS()
      
      • Environment Variables

      You can override default credentials by assigning values to the following environment variables:

      HERE_USER_ID
      HERE_CLIENT_ID
      HERE_ACCESS_KEY_ID
      HERE_ACCESS_KEY_SECRET
      HERE_TOKEN_ENDPOINT_URL
      

      Code snippet to instantiate LS object:

      from here_location_services import LS
      from here_location_services import PlatformCredentials
      
      ls = LS(platform_credentials=PlatformCredentials.from_env())
      
      • Credentials File

      You can specify any credentials file as an alternative to that found in ~/.here/credentials.properties. An error is generated if there is no file present at the path, or if the file is not properly formatted. Code snippet to instantiate LS object:

      from here_location_services import LS
      from here_location_services import PlatformCredentials
      
      platform_credentials = PlatformCredentials.from_credentials_file("<Path_to_file>")
      ls = LS(platform_credentials=platform_credentials)