OAuth Guide

Product(s)
Video Cloud
Role(s)
API Developer
Task(s)
Create & Configure Players
Topic(s)
Authentication
API(s)
Player Management API

Brightcove has created an OAuth 2 system that can be used across all of our new APIs for authorization. This topic shows you how to use OAuth to communicate with the Player Management API.

Introduction

You don't need to know anything about OAuth in order to use the system, and we'll explain everything you need to do to get started below. For a detailed overview of OAuth, see the Brightcove OAuth API documents.

To use OAuth authentication, follow these steps:

  1. Get your client credentials
  2. Get your access token
  3. Call Player Management API
  4. To simplify steps 2 and 3, use a server-side proxy

When working with the Player Management API, you can also use basic authentication. For details, see the Quick Start to Player Management document.

Get client credentials

To use OAuth, you first need to get your client credentials (client_id and client secret). These credentials are valid for the account(s) and API operation(s) that you are working with. This is a one-time operation provided that you save these credentials in a secure place for future use.

There are 2 ways to get your credentials:

Next, you will need to get an OAuth access token.

Get access token

The client credentials you got in the previous step are used to request your access token (access_token), which then provides authorization to make an API call. Since this token is only valid for 5 mins, in most cases you will need to get one for each API call that you make.

Follow these steps to get your access token using cURL:

  1. In your command line, use the export command to set the values for your client id and client secret.

    export CLIENT_ID=your client id value
              export CLIENT_SECRET=your client secret value
  2. Copy and paste the following cURL statement to your command line and press enter.

    curl
              -s
              --user $CLIENT_ID:$CLIENT_SECRET
              --header "Content-Type: application/x-www-form-urlencoded"
              --data "grant_type=client_credentials"
              https://oauth.brightcove.com/v3/access_token
  3. Your response should look similar to this:

    {"access_token":"AGUq5IQzLzrRvs8CNbhYlBFeB1_B6jTJrcE8grFHEJaPRsPeEg3-S_Apgv8VKiZ-nzxjDGtKwAco9q3z8tdzrxq76k6B9tUXk9HYQOIYgqziWbuvA50VaW8AK2MQFc0G3-woH_kgQxNQUaVNEpE1sePE9GUb2u9FfeQyLw8XQE_QfriYwkkcQoaGOusoIpujx8H6dLFovPuH5F5N3OSxNYhNZrdOhJwkdN7oe076j3xwNRarHn5IRPYKzjOMbqDk552aAhJxo2pYWoDh3q63pBrzre4Bj1rCHKJPifPEMrgPWzG1Uz1BPhQb5_ubr4P8mtnhCjJn4zzT_1-C8ActMUof45kVFhG4VTWRA8rh05THqEBj_TzPIR7L1t5oHhLo5ziILNSp7mZRM3folvYJC6YIhY7M4qLNGR5iq3nerlv5Ufr_bI-1AnP7a68JasawDpZxjfoGf3h6cwIZJr2uG_iU4FO9Ig-Gotaqv5mLWmUgR-DJ3sfRADc",
              "token_type":"Bearer",
              "expires_in":300}

With your access token, you are ready to communicate with the Player Management API.

Call Player Management API

To use OAuth to communicate with the Player Management API, you will need the access token that you generated in the previous section. Remember, that this token expires after 5 mins, so you may need to repeat the previous section steps if your access token has expired.

Follow these steps to get player configuration information using cURL:

  1. In your command line, use the export command to set the values for your access token, account id and player id.

    export ACCESS_TOKEN=your access token value
              export ACCOUNT_ID=your account id
              export PLAYER_ID=your player id
  2. Copy and paste the following cURL statement to your command line and press enter.

    curl
              --header "Content-Type: application/json"
              --header "Authorization: Bearer $ACCESS_TOKEN"
              --request GET
              https://players.api.brightcove.com/v2/accounts/$ACCOUNT_ID/players/$PLAYER_ID/configuration
  3. Your response should look similar to this:

    {"video_cloud":{"video":null,"policy_key":"BCpkADawqM3VpA66ktTO5bdLTmz6kLGMvGZrSyp-YTvbc4MHllmDmuwzEseO1uTeYYRqygGHhB_MgMaM6ndh5ch-cKYtMFx3LerHyziID8M19b162eeIXKYaxDf8uh4OsLTxVijM-qT1N5QR"},
              "stylesheets":["http://solutions.brightcove.com/bcls/brightcove-player/disabled-scrubber/disabled-scrubber.css"],
              "scripts":[],"plugins":[],
              "player":{"template":{"version":"1.14.22","name":"single-video-template"}},
              "autoadvance":0}

To learn about all the requests you can make to the Player Management API, see the Brightcove Player Management API reference document.