title: Problem getting Youtube Data API v3 OAuth2 token using REST endpoints
body: <p>I have been trying to get an YouTube OAuth2 token in react native using the following code:</p>
  <pre><code>let url =
    'https://accounts.google.com/o/oauth2/v2/auth?' +
    new URLSearchParams({
      client_id: encodeURIComponent(clientId),
      redirect_uri: encodeURIComponent('http://localhost:19006/oauth2callback'),
      scope: encodeURIComponent('https://www.googleapis.com/auth/youtube'),
      response_type: 'token'
    });
  
  //Fetch the URL
  fetch(url)
    .then(function (response) {
      // Log and return the response as JSON
      let rJson = response.json();
      console.log(rJson);
      return rJson;
    })
    .then(function (data) {
      // Log the API data
      console.log('token', data);
    })
    .catch(function (err) {
      // Log any errors
      console.log('something went wrong', err);
    });
  </code></pre>
  <p>I am getting the error:</p>
  <pre><code>SyntaxError: JSON Parse error: Unrecognized token '&lt;'
  </code></pre>
  <p>I have been stuck on this for ages even after looking at the <a href="https://developers.google.com/youtube/v3/guides/auth/client-side-web-apps" rel="nofollow noreferrer">YouTube Data API Client-side Web Apps Docs</a> no doubt it's something simple I don't see but help would be greatly appreciated</p>