Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <script type="text/javascript">
    function base64Encode(client_id, client_secret) {
    return window.btoa(client_id + ":" + client_secret);
  }
  
  function requestForAuthToken(url, client_id, client_secret) {
    var headers = new Headers({
      'Authorization': 'Basic ' + base64Encode(client_id, client_secret),
      'Content-Type': 'application/x-www-form-urlencoded'
    });
  
    fetch(url, {
        method: 'post',
        body: 'grant_type=client_credentials',
        mode: "no-cors",
        headers: headers
      })
      .then(
        function(response) {
          if (response.status !== 200) {
            console.log('Looks like there was a problem. Status Code: ' +
              response.status);
            return;
          }
  
          // Examine the text in the response as JSON
          response.json().then(function(data) {
            console.log(data);
          });
        }
      )
      .catch(function(err) {
        console.log('Fetch Error :-S', err);
      });
  }
  
  requestForAuthToken('https://oauth.brightcove.com/v4/access_token', 'client_id', 'client_secre');
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
aruprakshitpro
0viewers