Refreshing Tokens

Parameters
grant_type:This value should be set to refresh_token
refresh_token:The refresh token received from the code exchange or a previous refresh_token grant
client_id:Client id of your Restream API application
client_secret:Client secret of your Restream API application

There are two ways to refresh tokens:

  1. Using a Basic Auth header to send the client_id and client_secret
  2. Use the client_id and client_secret as part of the x-www-form-urlencoded body
Tip

Use the Basic Auth header to prevent passing confidential information as part of a query string that could be logged. For example a web server hosting an Nginx load balancer could log the request with the full query string.

You can refresh an access token by sending a POST request to the following URL:

curl -X POST \
     -H "Content-Type: application/x-www-form-urlencoded" \
     --user [your client id]:[your client secret] \
     --data "grant_type=refresh_token&refresh_token=[refresh token]" \
     https://api.restream.io/oauth/token

Upon a successful refresh, the previous access & refresh token pair will be invalidated and you will receive a new pair of tokens with new expiration times. The expiration time for access tokens is 1 hour and 1 year for refresh tokens from the time of grant.

Warning

Because this endpoint requires the submission of the client_secret, user's devices should never have or use the secret to make refresh requests directly to Restream. Instead, their device should make a request to a proxy endpoint provided by the client web application. The client should then forward the request with the appropriate credentials to the refresh token route listed above and relay the results back to the user.

Response

Success
Error
{
  "access_token": "7e61c8a5e2f99404730c511de6580412e618da35",
  "expires": 1520280099,
  "expires_in": 3600,
  "refresh_token": "0e633c3343a2df84b1526f4c2e6993ff17e05cab",
  "scope": "profile.read channels.read chat.read stream.read",
  "token_type": "Bearer",
  "accessToken": "7e61c8a5e2f99404730c511de6580412e618da35",
  "accessTokenExpiresIn": 3600,
  "accessTokenExpiresAt": "2018-03-05T20:01:38.518Z",
  "accessTokenExpiresEpoch": 1520280099,
  "refreshToken": "0e633c3343a2df84b1526f4c2e6993ff17e05cab",
  "refreshTokenExpiresIn": 31536000,
  "refreshTokenExpiresAt": "2019-03-05T19:01:38.518Z",
  "refreshTokenExpiresEpoch": 1551812499,
  "scopeJson": [
    "profile.read",
    "channels.read",
    "chat.read",
    "stream.read"
  ],
  "tokenType": "Bearer"
}