Basic Auth headers with Citizen Space
Last updated
Last updated
Basic Authentication is a common approach for authenticating to an API. Often it's the case where it's the base64 encoding of username and a password separated by a colon like so username:password.
Authenticating to an API in Citizen Space requires a request header is sent in the following format:
Key = 'Authorization'
Value = 'Basic' + base 64 encoding of a key and secret combined with a colon
Citizen Space makes it particularly easy to generate, manage, and use keys and you can see where you would collect this information from in the image below.
The below key is for demonstration purposes only and is not valid
In this example we want to replicate a scenario in which a person in an organisation has asked to pull the latest site wide activity data from our Citizen Space into a third party analysis tool.
We can do that simply by amending the site URL:
GET
/
api/1/activities
Return a filtered list of all activities.
Without proper authentication this will return an error:
By encoding our key and secret and using Basic Authentication we can return the following:
GET
/
api/1/activities
Return a filtered list of all activities.
Headers
Authorization
Basic MjcxMzI3RENGQzVCNEU3NEE0MDI0NDkxMDM4QS4uLi46dkVta3NLQThSSEFYWXM2V01rWFpydmJ4UUthNjJyMnV6Q3h3ZndoWktXNmZ5Z0JDTWJZeHpEdlRVNy4uLi4=
Response