Locate APIs use OAuth 2.0 protocol to authenticate and authorize the API request using an OAuth token.
Follow the below steps to generate token and access Locate APIs.
Step 1) Getting API Key and Secret
Register or Log-in to your PB Developer's account from https://locate.pitneybowes.com/. Get your API Key and Secret from API Keys page in your Dashboard from https://developerportal.pitneybowes.com/software-apis/apikeys
Step 2) Generating OAuth Access Token
Generate a base64 value of your credentials (API Key and Secret) in following format, as shown below:
{base64Value} = base64encode(APIKey:secret)
Make a POST request using the base64value to generate the access token, as shown below:
POST
https://api.pitneybowes.com/oauth/token
Request body:
grant_type=client_credentials
Request Headers:
Content-Type: application/x-www-form-urlencoded
Authorization: Basic {base64Value}
The Response from above POST request contains OAuth access token, as shown below:
{"access_token":"{your access token}" .............}
Step 3) Accessing API using OAuth Token
Make a request to Locate APIs using the OAuth token in authorization header.
For example, to call the GeoSearch Locate API, use the following URL and header in the request:
https://api.pitneybowes.com/location-intelligence/geosearch/v2/locations?searchText=1%20Global%20V&country=USA Authorization: Bearer {access_token}
Step 4) Refreshing Access Token
Access token have limited lifetime. If the token expires, use Step 2 to generate a new token.
If the error code in Locate API response is PB-APIM-ERR-1003 or PB-APIM-ERR-1002, it means token has expired and needs to be regenerated.
Accessing GeoMap API doesn't require an OAuth Token. It can be accessed using only the API Key.
------------------------------
Neha Gupta
Pitney Bowes Software India PVT. Ltd
Noida
------------------------------