title: Apps Script & Oauth2 & Youtube API v3
body: <p>I have <a href="http://devtest.lagaroo.com.br/dev-test/dev-test-youtube" rel="nofollow">This script</a> that lists my favorite videos of youtube using Oauth and the YTB API v2.</p>
  
  <p>Now I would like to do the same with the YTB DATA API V3 and who knows an easy step ahaed is the YTB ANALYTICS API V1. </p>
  
  <p>So I was looking for the URL that would get me to the favorites in V3.<br>
  <code>var URL = "https://www.googleapis.com/youtube/v3/"</code><br>
  instead of <br>
  <code>//var URL = "http://gdata.youtube.com/feeds/api/users/default/favorites?v=2";</code></p>
  
  <p>Is that there a way to do it like this with the DATA API v3? 
  Or is it only possible to reach to the simple data with the long URL request with the API KEY as in the <a href="https://github.com/entaq/GoogleAppsScript/blob/master/YouTube/YouTubeAnalytics.gs" rel="nofollow">github example</a> of @Arun Nagarajan
  <code>var url = 'https://www.googleapis.com/youtube/v3/activities?'
                +'part=snippet&amp;channelId=UC_x5XG1OV2P6uZZ5FSM9Ttw&amp;maxResults=20&amp;publishedBefore=2013-02-25T00:00:00.0Z'
                +'&amp;key='+API_KEY;
  </code></p>
  
  <p>Here is the part of the code that I would like to use with the YTB API v3.</p>
  
  <pre><code>//var URL = "http://gdata.youtube.com/feeds/api/users/default/favorites?v=2"; works
  var URL = "https://www.googleapis.com/youtube/v3/" // cant find it
  function getFavoriteVideos() 
  {
   var data = UrlFetchApp.fetch(URL, googleOAuth_()).getContentText(); 
   var xmlOutput = Xml.parse(data, false);  
   var favorites = xmlOutput.getElement().getElements('entry');  
   Logger.log("a" + favorites.length.toString())
   var a = favorites.length.toString()
   for(var i = 0; i &lt; favorites.length; i++)
   {
     favorites[i].getElement('title').getText()
     Logger.log(favorites[i].getElement('title').getText())
   }
  }
  </code></pre>
  
  <p>The authentication</p>
  
  <pre><code>var NAME = 'youtube';
  var SCOPE = 'http://gdata.youtube.com';
  
  function googleOAuth_() {
   var oAuthConfig = UrlFetchApp.addOAuthService(NAME);
   oAuthConfig.setRequestTokenUrl('https://www.google.com/accounts/OAuthGetRequestToken?scope='+SCOPE);
   oAuthConfig.setAuthorizationUrl('https://www.google.com/accounts/OAuthAuthorizeToken');
   oAuthConfig.setAccessTokenUrl('https://www.google.com/accounts/OAuthGetAccessToken');
   oAuthConfig.setConsumerKey('anonymous');
   oAuthConfig.setConsumerSecret('anonymous');
   return {oAuthServiceName:NAME, oAuthUseToken:'always'};
  }
  </code></pre>