Authenticate to the HERE platform using client credentials

To authenticate with the HERE platform, you must get platform credentials that contain the access key ID and access key secret.

To authenticate using client credentials:

  1. Get your platform credentials.

    For instructions, see the Get Credentials section in the Terms and Permissions User Guide.

    You get the credentials.properties file.

  2. Set your credentials in one of the following ways:

    • (For Node.js only) Get your credentials from the file using the loadCredentialsFromFile helper method.

      const credentials = loadCredentialsFromFile("Path");
      
    • (For browser and Node.js) Set credentials manually using the here.access.key.іd and here.access.key.secret from the credentials.properties file.

      const credentials = {
        accessKeyId: "replace-with-your-access-key-id",
        accessKeySecret: "replace-with-your-access-key-secret"
      };
      
  3. Import the requestToken method and the UserAuth module from the olp-sdk-authentication module.

    import { UserAuth, requestToken } from "@here/olp-sdk-authentication";
    
  4. Create the UserAuth instance using the environment in which you work, your credentials, and the tokenRequester method.

    Note: Depending on the environment that you use, specify one of the following parameters: env or customUrl. Use env for the here, here-dev, here-cn, and here-cn-dev environments, and customUrl – for your custom environment.

    const userAuth = new UserAuth({
      env: "here | here-dev | here-cn | here-cn-dev",
      customUrl: "http://YourCustomEnvironment",
      credentials: credentials,
      tokenRequester: requestToken
    });
    
  5. Get the OAuth 2.0 token from the HERE platform using the getToken method.

    const token: string = await userAuth.getToken();
    

You can use the UserAuth instance to create the OlpClientSettings object. For more information, see Create platform client settings.

results matching ""

    No results matching ""