API Authorization

To connect to BidSwitch using one of its APIs, use the following steps.

  • Create an API user in your myBidSwitch UI account.

  • Using this user’s credentials, get your API token by making a POST request to the BidSwitch authorization endpoint.

  • Pass this token in your request header Authorization:Bearer ${TOKEN}

Creating an API User

To create a user profile that can receive API Tokens, use the following steps. Once created you can get get a permanent token or request short lived temporary tokens:

  1. From the BidSwitch UI, select Users ‣ Add User.

  2. From the User Role dropdown menu, select API Account.

Permanent Auth Tokens

To get a permanent auth token for your integration, use the following steps.

  1. Log into the BidSwitch single sign-on management portal: https://uauth.bidswitch.com/uauth/settings/#sso

  2. Select OAuth2 Access Token ‣ New Permanent Token

  3. Set the scope to api.bidswitch.com, and Create

  4. Save the generated token for use with your API requests, this token must be passed in request headers

Temporary Auth Tokens

To get a temporary auth token for your integration, use the following steps. Make an HTTP POST request to the following URL. The response will contain your access token and its expiration time. You can use this token to perform API requests until the token expires.

Auth Token POST Details

Endpoint Info

Description

endpoint

https://uauth.iponweb.com/oauth2/token/

Method

POST

headers

Content-Type and Accept {'Content-Type': 'application/x-www-form-urlencoded', 'accept': 'application/json'}

username

(Required) Your UI username

password

(Required) Your UI password

scope

(Required) The service to which your user token should grant you access, e.g. "scope=service_id=api.bidswitch.com"

Example Using Curl
curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' -H 'accept: application/json' -d 'grant_type=password&username=${username}&password=${password}&scope=service_id=api.bidswitch.com' 'https://uauth.iponweb.com/oauth2/token/'
Example Using Python Requests
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
import requests

headers = {
    "Content-Type": "application/x-www-form-urlencoded",
    "accept": "application/json",
}
payload = {
    "grant_type": "password",
    "username": login,  # Your UI Login
    "password": password,  # Your UI Password
    "scope": "service_id=api.bidswitch.com",
}
token_post = requests.post(
    "https://uauth.iponweb.com/oauth2/token/", params=payload, headers=headers
)
response_json = token_post.json()
token = response_json["access_token"]

print(token)
Sample AUTH Response
{
  "token_type": "Bearer",
  "scope": "api.bidswitch.com",
  "access_token": "<access_token>",
  "expires_in": 3600,
  "last_chars": "<last chars of auth token>"
}