API Authentication (PREVIEW)

Note

This authentication method is currently in preview and is subject to breaking changes. It is based on a different request than the rest of the bronID API.

Overview

The authentication methods in this file support two types of authentication headers: Basic Authentication and API Key Authentication. Both methods extract use the serviceUid and apiKey parameters from the Authorization header of the HTTP request.

Authentication Methods

Basic Authentication

When authenticating using Basic Authentication, the Authorization header value sent with the request should start with the keyword Basic. The credentials should be base64-encoded in the format {{SERVICE_UID}}:{{SECRET_KEY}}.

Example header: Authorization: Basic dXNlcklkOmFwaUtleQ== (where dXNlcklkOmFwaUtleQ== is the base64 encoding of {{SERVICE_UID}}:{{SECRET_KEY}}).

How to setup in Postman:

  • when creating a request (e.g. a GET or POST request), click the Authorization tab which is located below the URL field
  • select Basic Auth from the Auth type dropdown menu
  • enter your serviceUid and secretKey in the Username and Password fields respectively.
  • Postman will automatically encode the credentials in the base64 format.

API Key Authentication

When authenticating using API Key Authentication, the Authorization header value sent with the request should start with the keyword ApiKey. The credentials should be in the format {{SERVICE_UID}}:{{SECRET_KEY}}.

Example header: Authorization: ApiKey {{SERVICE_UID}}:{{SECRET_KEY}}

How to setup in Postman:

  • when creating a request (e.g. a GET or POST request), click the Authorization tab which is located below the URL field
  • select API Key from the Auth type dropdown menu
  • in the Key field, enter Authorization (this is a fixed value and represents the header name)
  • in the Value field, enter your serviceUid and secretKey along with the ApiKey prefix in the following format: ApiKey {{SERVICE_UID}}:{{SECRET_KEY}}
  • select Header from the Add to dropdown menu

Code samples

JavaScript

Basic Authentication

const axios = require('axios'); // Encode credentials in base64 const credentials = 'YOUR_SERVICE_UID:YOUR_SECRET_KEY'; const credentialsBase64 = Buffer.from(credentials).toString('base64'); // Authenticate with Basic Authentication // Option 1: Set header manually let config = { method: 'get', url: 'https://dev.bronid.com/v5/lookup?id=33051775556&country=AUS', headers: { 'Authorization': `Basic ${credentialsBase64}` } }; /* Option 2: use "auth" parameter - automatically sets the Authorization header let config = { method: 'get', url: 'https://dev.bronid.com/v5/lookup?id=33051775556&country=AUS', auth: { username: 'YOUR_SERVICE_UID', password: 'YOUR_SECRET_KEY' } }; */ // Make a request with Basic Authentication const response = await axios.request(config);

API Key Authentication

const axios = require('axios'); const credentials = 'YOUR_SERVICE_UID:YOUR_SECRET_KEY'; // Create config object for API Key Authentication let config = { method: 'get', url: 'https://dev.bronid.com/v5/lookup?id=33051775556&country=AUS', headers: { 'Authorization': `ApiKey ${credentials}` } }; // Make a request with API Key Authentication const response = await axios.request(config);

Python

Basic Authentication

import requests from requests.auth import HTTPBasicAuth # Define credentials service_uid = 'YOUR_SERVICE_UID' secret_key = 'YOUR_SECRET_KEY' # Make a request with Basic Authentication response = requests.get( 'https://dev.bronid.com/v5/lookup?id=33051775556&country=AUS', auth=HTTPBasicAuth(service_uid, secret_key) ) // responses are returned as JSON objects data = response.json()

API Key Authentication

import requests # Define credentials credentials = 'YOUR_SERVICE_UID:YOUR_SECRET_KEY' # Make a request with API Key Authentication response = requests.get( 'https://dev.bronid.com/v5/lookup?id=33051775556&country=AUS', headers={'Authorization': f'ApiKey {credentials}'} ) // responses are returned as JSON objects data = response.json()

C#

Basic Authentication

using System; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; class Program { static async Task Main() { var client = new HttpClient(); var credentials = "YOUR_SERVICE_UID:YOUR_SECRET_KEY"; var credentialsBase64 = Convert.ToBase64String(Encoding.ASCII.GetBytes(credentials)); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentialsBase64); var response = await client.GetAsync("https://dev.bronid.com/v5/lookup?id=33051775556&country=AUS"); var jsonString = await response.Content.ReadAsStringAsync(); // responses are returned as JSON objects var data = JsonSerializer.Deserialize<YourDataType>(jsonString); Console.WriteLine(data); } }

API Key Authentication

using System; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { var client = new HttpClient(); var credentials = "YOUR_SERVICE_UID:YOUR_SECRET_KEY"; client.DefaultRequestHeaders.Add("Authorization", $"ApiKey {credentials}"); var response = await client.GetAsync("https://dev.bronid.com/v5/lookup?id=33051775556&country=AUS"); var jsonString = await response.Content.ReadAsStringAsync(); // responses are returned as JSON objects var data = JsonSerializer.Deserialize<YourDataType>(jsonString); Console.WriteLine(data); } }