Accessing the Location Services API

The bearer token duration (seconds) is available in the "expires_in" field. In our example, we have a TTL of 3600s (1h). This means that we can use the same token for all Location Services API calls in that period of time. After this, it expires and we need to generate a new one.

The Location Services API calls use the OAuth 2.0 bearer token authorization schema. This includes all operations such as creating, retrieving, changing and deleting locations, each of which, represented by a permission that needs to be present on the scope JSON field value.

In practical terms, all requests to Location Services must have an "Authorization" request header with the "Bearer " prefix, followed by the token (copied from access_token JSON field value).

Example

Request

GET /dmoptions/locations/e8ca062c-6921-43d5-a857-aea5ca562690 HTTP/1.1
Host: dmo.metapack.com
Content-Type: application/json
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1R1oyS0NWQzBXTDJMM1E1UVdITjA4SUw1IiwiaXNzIjoiaHR0cHM6Ly9hcGkuc3Rvcm1wYXRoLmNvbS92MS9hcHBsaWNhdGlvbnMvN01ibXRzWVRhSjBQOEY0bjBseHVJOSIsImlhdCI6MTQyMTI0NjU3MSwiZXhwIjoxNDIxMjUwMTcxLCJzY29wZSI6ImNhbi1jckVhdGUtbG9jYXRpb25zIGNhbi1kZWxldGUtb3duLWxvY2F0aW9ucyBjYW4tdXBkYXRlLW93bi1sb2NhdGlvbnMgY2FuLWNyZWF0ZS1vd24tbG9jYXRpb24tcnVsZXMgIn0.HMoDne2AHWcAQCghCWbGRVbZeXITMfVA31t8HPUP4Rw

Response

HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With,Content-Type
Access-Control-Allow-Methods: GET,PUT,POST,DELETE
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Thu, 15 Jan 2015 16:35:47 GMT
Server: Jetty(9.2.z-SNAPSHOT)
Transfer-Encoding: chunked
{
    "address": "Doddle Waterloo; Waterloo Station; Waterloo Road",
    "city": "London",
    "countryCode": "GBR",
    "description": null,
    "hasDisabledAccess": false,
    "id": "e8ca062c-6921-43d5-a857-aea5ca562690",
    "latitude": 51.502903,
    "links": [
        {
            "href": "/locations/e8ca062c-6921-43d5-a857-aea5ca562690",
            "rel": "self"
        },
        {
            "href": "/locations/e8ca062c-6921-43d5-a857-aea5ca562690/details",
            "rel": "details"
        }
    ],
    "locationProvider": {
        "id": "5b1f0987-6636-4bfb-b4e0-0c8351f84780",
        "name": "Doddle"
    },
    "logoUrl": null,
    "longitude": -0.1129436,
    "photoUrls": [],
    "postCode": "SE1 7LY",
    "storeId": "4",
    "storeName": "Waterloo",
    "telephoneNumber": "+442076203777"
}

results matching ""

    No results matching ""