Refreshing an Expired Token

In this step we show how to refresh an expired access token.

Setup

Execute the following line to load the libraries:


In [ ]:
require('/opt/notebooks/tutorial/lib/tutorial-utils')(this);

Refreshing an access token

To obtain a new access token to replace an expired token, the client makes a POST /token request with the following parameters:

  • grant_type: The value "http://tech.ebu.ch/cpa/1.0/client_credentials".
  • client_id: The unique identifier for the client given by the authorization provider.
  • client_secret: A shared secret value between the client and authorization provider.
  • domain: The service provider domain.

The client must have an existing access token for the given domain. After making this request, the previous access token is no longer valid, and is replaced by the new token.


In [ ]:
this.post("http://ap:8001/token", {
  grant_type: "http://tech.ebu.ch/cpa/1.0/client_credentials",
  client_id: "<client_id>",
  client_secret: "<client_secret>",
  domain: "sp:8002"
});

Using the new access token

We can now use the new access token in a request to the service provider.


In [ ]:
this.post("http://sp:8002/radiodns/tag/1/tag", {
  time_source: "user",
  bearer: "0.c221.ce15.ce1.dab",
  time: 1441792800
}, { form: true, token: "<access-token>" });

Viewing the tags

You can see the tags stored by the Service Provider here.