Tokens - GetBric/API GitHub Wiki

Tokens are how you authenticate through the API.

Creating a Token

  • Route: /tokens
  • Method: POST
  • Data Required: You need to Base64 encode your Bric email and password separated by a colon. So if you log in to Bric with [email protected] and a password of ilovebric44, you will want to encode the string [email protected]:ilovebric44. That encoded string needs to be passed in the Authorization header with the word 'Basic' prepended to it, so you'll use something that looks like Basic ZXhhbXBsZUB0ZXN0LmNvbTppbG92ZWJyaWM0NA== except with your encoded string. You also need to pass a Company header with the name of the subdomain you use with Bric.
  • Expected Response:
{
  "tokens": {
    "id": 93,
    "link": "https://api.getbric.com/v1/tokens/93",
    "secret": "9f0ff8930a5344b30220927d1f53b368c55578ce",
    "user": {
      "email": "[email protected]"
    },
    "created_at": "2016-04-14T17:47:09.522-04:00",
    "updated_at": "2016-04-14T17:47:09.522-04:00"
  }
}

Using your Token

After creating a token, you will then need to encode your token secret in the same manner as you did above, again with the word Basic prepended. You do not need to include the Company header any longer.

Token Index

  • Route: /tokens
  • Method: GET
  • Expected Response:
{
  "tokens": [
    {
      "id": 93,
      "link": "https://api.getbric.com/v1/tokens/93",
      "secret": "9f0ff8930a5344b30220927d1f53b368c55578ce",
      "user": {
        "email": "[email protected]"
      },
      "created_at": "2016-04-14T17:47:09.522-04:00",
      "updated_at": "2016-04-14T17:47:09.522-04:00"
    },
    {
      "id": 94,
      "link": "https://api.getbric.com/v1/tokens/94",
      "secret": "ee22a962b68e6683ab44dc6126990df318497f1e",
      "user": {
        "email": "[email protected]"
      },
      "created_at": "2016-04-14T17:50:50.545-04:00",
      "updated_at": "2016-04-14T17:50:50.545-04:00"
    }
  ]
}

Token Destroy

  • Route: /tokens/id
  • Method: DELETE
  • Expected Response:
{
  "tokens": {
    "id": 92,
    "link": "https://api.getbric.com/v1/tokens/92",
    "secret": "8b6ddbef46676fa799d68bc9e2961f9b4912b57d",
    "user": {
      "email": "[email protected]"
    },
    "created_at": "2016-04-12T16:00:58.150-04:00",
    "updated_at": "2016-04-12T16:00:58.150-04:00"
  }
}