Authentication Overview

Ola Maps's APIs can use API keys or JWT for authentication. User can get both set of credentials.

Creating Credentials

To begin using Ola Maps' geolocation APIs and map tiles API, users need to create credentials in the Ola Maps Developer Portal. Follow the steps below to create credentials.

Step 1: Navigate to the credentials section.

Step 2: Click on the "New Credentials" button in top right corner.

Create Project

Step 3: Provide a name for your credentials and description.

Provide project details

Step 4: Upon creation, credentials will be listed in table.

Provide project details

Step 5: Click on credentials name to display details. This page will show API Key and OAuth2 client credentials.

Provide project details

Step 6: Add your domains as comma seperated values and click on add button to whitelist your client credentials.

Provide project details

Using API Keys to Call Map APIs

Following shells script demonstrates use of API Keys. Copy one of API Keys from credentials and replace it "api_key"

searchText="Taj%20Mahal"
apiKey="api_key"
curl --location "https://api.olamaps.io/places/v1/autocomplete?input=${searchText}&api_key=${apiKey}"

Using JWT to Call Map APIs

Similaraly below script demonstrates use of JWT. First API call retrieves access token from OLA Maps authentication service. It is further used as bearer token to call Autocomplete API

clientId="client_id"
clientSecret="client_secret"

accessToken=$(
  curl --silent --request POST \
  --location "https://account.olamaps.io/realms/olamaps/protocol/openid-connect/token" \
  --data "grant_type=client_credentials" \
  --data "scope=openid" \
  --data "client_id=${clientId}" \
  --data "client_secret=${clientSecret}" | jq -r '.access_token'
)

echo "Access Token: ${accessToken}"

curl --silent \
--header "Authorization: Bearer ${accessToken}" \
--location "https://api.olamaps.io/places/v1/autocomplete?input=${searchText}" | jq