Getting started
Last updated
Was this helpful?
Last updated
Was this helpful?
This guide shows you how to get started using the OAuth 2 API. It takes you through the process of:
Generating an access token using the OAuth 2 API endpoint.
Using the access token to access OS Data Hub APIs.
Basic knowledge of the command line.
curl command line tool. Windows 10 (v1803) and later, and macOS, both come with a bundled curl tool
A project in the OS Data Hub. See Getting started with an API project for more information.
The following instructions demonstrate how to generate an access token using the OAuth 2 API, and to then use that access token to access the OS Maps API.
Open a command line window (how you do this depends on your operating system).
Type or copy the following into the command line while substituting projectAPIKey
and projectAPISecret
with your project’s API key and secret:
Execute the command by pressing Enter.
The response should look similar to the following:
{accessToken}
is the access token you need for requests to OS Data Hub APIs
{expiryPeriod}
is the length in seconds until the access token expires.
issuedTimestamp}
is the timestamp of when the access token was issued.
If an access token is not generated, check that you have copied over the API Key and Secret correctly, and that they are surrounded by double quotes, and separated by a colon. You may also find it helpful to add the --verbose
flag to the curl command while debugging the issue.
Type or copy the following into the command line while substituting {accessToken}
with the access token returned in the previous step.
Note that the value of the Authorization header is the word Bearer, then a space, and then the access token.
If successful, this will return the GetCapabilities document for OS Maps API (WMTS).