LogoLogo
OS Docs HomeOS NGDOS APIsOS Download ProductsMore than MapsOS Data Hub
  • Introduction to OS APIs
  • Core Concepts
    • Getting started with an API project
    • Authentication
    • Error codes
    • Rate-limiting policy
    • OS API branding
    • Service level agreements
    • Service availability dashboard
  • Accessing OS APIs
    • OS Maps API
      • Layers and styles
      • Getting started
        • ESRI ArcGIS Online
        • ESRI ArcGIS Pro
        • ESRI ArcMap
        • Cadcorp SIS
        • MapInfo Pro
        • QGIS
      • Technical specification
        • ZXY
        • WMTS
      • Code examples
    • OS Vector Tile API
      • What data is available?
      • Getting started
        • ESRI ArcGIS Pro
        • Cadcorp SIS
        • QGIS
        • Create a web application using the OS Vector Tile API
      • Technical specification
        • Service Metadata
        • Stylesheet
        • Tile request
      • Code examples
      • Stylesheets
    • OS NGD API – Tiles
    • OS NGD API – Features
    • OS Features API
      • OS Product Archive
      • What data is available?
      • Getting started
        • ArcGIS Online
        • ArcGIS Pro
        • ArcMap
        • Cadcorp SIS
        • MapInfo Pro
        • QGIS
      • Technical specification
        • getCapabilities
        • describeFeatureType
        • getFeature
        • Filtering
        • Paging
        • Empty values
      • Code examples
    • OS Names API
      • Getting started with example queries using Node.js
      • Technical specification
        • Find
        • Nearest
      • Code list
      • Code examples
    • OS Linked Identifiers API
      • What data is available?
      • Getting started with implementing a look-up application
      • Technical specification
        • Identifier
        • Identifier Types
        • Feature Types
        • Product Version Information
      • Code examples
    • OS Places API
      • Getting started with example queries using Node.js
      • Technical specification
        • Find
        • Postcode
        • UPRN
        • Nearest
        • BBOX
        • Radius
        • Polygon
      • Datasets
      • Code lists
      • Code examples
    • OS Match & Cleanse API
      • End of Life Information
      • Getting started with an example match query using Node.js
      • Technical specification
      • Datasets
      • Code lists
    • OS Downloads API
      • Getting started
        • Automating OS OpenData downloads
        • Automating OS Premium data downloads
      • Technical specification
        • OpenData products
        • OpenData product details
        • Download an OpenData product
        • OpenData product image
        • Data packages
        • Data package ID
        • Data package version
        • Data package version ID
        • Download a data package
    • OAuth 2 API
      • Getting started
      • Technical specification
  • Additional resources
    • OS API Wrappers
      • JavaScript
      • Python
      • R
  • Extra Links
    • Accessibility
    • Contact us
    • PSGA Product Summary
    • Terms and conditions
Powered by GitBook
On this page
  • API reference
  • Generate access token

Was this helpful?

  1. Accessing OS APIs
  2. OAuth 2 API

Technical specification

PreviousGetting startedNextOS API Wrappers

Last updated 3 months ago

Was this helpful?

This technical specification explains the content of the OS OAuth2 API.

If you are not familiar with the OS OAuth 2 API please read the before proceeding.

API reference

Generate access token

POST /

To create an access token, you must send a HTTP POST request to the OS DataHub OAuth 2 token endpoint. The endpoint is secured with HTTP Basic Authentication, where the username is the Project API Key and the password is the Project API Secret.

Required HTTP Headers

Name
Value
Description

Content-Type

application/x-www-form-urlencoded

The encoded credentials are a base-64 encoded version of a string containing the username (Project API Key), a single : and the password (Project API Secret). Once you have the encoded value you should set the value of the Authorization header to 'Basic', a space, and the encoded value, e.g. Basic <encodedValue>.

Authorization

Basic <encoded credentials>

The request body must be form-encoded.

Many HTTP frameworks have support for form-encoded messages and will set the content type automatically.

Body

Name
Value
Description

grant_type

client_credentials

The only supported grant_type is client_credentials

Response

The response body is returned as a JSON object with the following properties:

Name
Example Value
Description

access_token

ZclClFcksJlZ19vnJOt09Yj3xme0

The new access token.

expires_in

299

The time until the token expires, in seconds.

issued_at

1576249823754

The time at which the token was created.

token_type

Bearer

The type of the token. This is always Bearer.

{
  "id": 1,
  "name": "John",
  "age": 30
}

Once you have generated your access token, you can use it to authenticate your requests to other OS Data Hub APIs.

To use the access token you must include an Authorization header on your API request. The value of the Authorization header should be 'Bearer', a space, and then the access token, for example, Bearer <accessToken>.

overview documentation