Butlr Developer Docs
  • Welcome
  • What is Butlr
  • Spatial Metrics
  • Getting Started
    • Authentication
    • Making your first query
    • Mint Client Credentials
  • Changelog
  • Asset Management
    • GraphQL API Overview
      • Sites
      • Buildings
      • Floors
      • Rooms
      • Zones
      • Hives
      • Sensors
      • Asset Tags
    • GraphQL API Introsepction
  • Historical Occupancy
    • Reporting API Overview
      • Floor Occupancy
      • Room Occupancy
      • Zone Occupancy
      • Query Occupancy by Tag
      • Traffic
      • Presence Time
      • Statistic Overview
    • FAQs
  • Real-time occupancy
    • Webhooks Overview
      • Area Detections
      • Entryway Traffic
      • Floor Occupancy
      • Room Occupancy
      • Zone Occupancy
      • Motion Detection
      • No Motion Detection
    • Manage Webhooks
      • Create Webhooks
      • Update Webhooks
      • Delete Webhooks
      • List Webhooks
  • LINKS
    • Butlr Postman Collection
    • Butlr Website
    • Status
    • Support
    • Log In
Powered by GitBook
On this page
  • OAuth 2.0 Password Grant
  • OAuth 2.0 Client Credentials Grant
  1. Getting Started

Authentication

PreviousGetting StartedNextMaking your first query

Last updated 22 days ago

Request

curl --location --request POST 'https://api.butlr.io/api/v2/login' \
--header 'Content-Type: application/json' \
--data-raw '{
    "username": "your@email.com",
    "password": "your_password"
}'
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.butlr.io/api/v2/login"
  method := "POST"

  payload := strings.NewReader(`{
    "username": "your@email.com",
    "password": "your_password"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
import requests
import json

url = "https://api.butlr.io/api/v2/login"

payload = json.dumps({
  "username": "your@email.com",
  "password": "your_password"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Response

{
    "access_token": "your_access_token",
    "refresh_token": "your_refresh_token",
    "id_token": "your_id_token",
    "scope": "your_scopes",
    "expires_in": 1000,
    "token_type": "Bearer"
}

How to create your client credentials

  1. Sign in using your username and password.

  2. Click the expandable menu (v) in the top navigation bar (upper right corner) and select Account Settings.

  1. Navigate to the API tokens tab.

  2. Click the Create token button.

  3. Enter a Name and a Description, then click Create.

  4. A dialog box will display your Client ID and Client Secret.

  • ⚠️ Important: Be sure to copy and securely store these credentials. For security reasons, they will not be shown again after you close the dialog.

Request

curl --location --request POST 'https://api.butlr.io/api/v2/clients/login' \
--header 'Content-Type: application/json' \
--data '{
    "client_id": "your_client_id",
    "client_secret": "your_client_secret",
    "audience": "https://butlrauth/",
    "grant_type": "client_credentials"
}'
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.butlr.io/api/v2/clients/login"
  method := "POST"

  payload := strings.NewReader(`{
    "client_id": "your_client_id",
    "client_secret": "your_client_secret",
    "audience": "https://butlrauth/",
    "grant_type": "client_credentials"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
import requests
import json

url = "https://api.butlr.io/api/v2/clients/login"

payload = json.dumps({
  "client_id": "your_client_id",
  "client_secret": "your_client_secret",
  "audience": "https://butlrauth/",
  "grant_type": "client_credentials"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Response

{
    "access_token": "your_access_token",
    "scope": "your_scopes",
    "expires_in": 1000,
    "token_type": "Bearer"
}

Go to the .

OAuth 2.0 Password Grant
OAuth 2.0 Client Credentials Grant
Butlr Web App