Welcome to the OpenCities help centre. Search for what you're after, or browse the categories.
Can't find what you're looking for? Submit a support ticket and we'll be in touch.


Basic Authentication

avatar of Andrew Prillaman

Andrew Prillaman

Last updated

This is a Developer task

The Rest API now offers Basic Authentication (Basic Access Authentication) as an authentication method.

The authentication header should be sent with every request with the schema set to Basic followed by the parameters and signature as below.

Authorization: Basic (Base64 Encoded(<<AppId>>:<<APIKey>>))

The authorization header is generated using the following steps.

  1. The AppId and APIkey are combined with a single colon (:).
    • eg. "a55dc6aa-30ef-4b9a-bba8-afa001315072:9uIiAWiDssv7B8k7AqVOFnul27qwjsViBhIA2v4DBmI6"
  2. The resulting string is encoded into an octet sequence using ASCII Encoding.
  3. The resulting string is encoded using Base64.
  4. The authorization method and a space (e.g. "Basic ") is then prepended to the encoded string.

PowerShell Example

# Example Appid: a55dc6aa-30ef-4b9a-bba8-afa001315072
# Example APIKey: 9uIiAWiDssv7B8k7AqVOFnul27qwjsViBhIA2v4DBmI6

# Create the string (AppId:APIKey) and generate the octet sequence.
$basicbytes = [System.Text.Encoding]::ASCII.GetBytes(

# Encode the octet sequence to Base64.
$basicbase64 = [Convert]::ToBase64String($basicbytes)

# Complete the header value.
$basicvalue = "Basic "+$basicbase64

# Create a new Header object.
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

# Add the Authorization Header to the Header object.
$headers.Add("Authorization", $basicvalue )

Was this article helpful?
0 out of 0 found this helpful