title: Right way to use YouTube.Builder
body: <p>I need to get user youtube videos. Here is my code which only tries to get user youtube channels. But it does not work - after choosing account, <em>loadYoutubeChannels</em> always thows errors. I read this <a href="https://stackoverflow.com/a/21407747/5468694">answer</a> and this <a href="https://github.com/youtube/yt-direct-lite-android/tree/master/app/src/main/java/com/google/ytdl" rel="nofollow noreferrer">yt-direct-lite-android</a>, but still don't understand why they do not get errors, but i get. 
  <br>
  Here is my code:</p>
  
  <pre><code>class YotubeTestActivity extends AppCompatActivity {
  
    private var credential: GoogleAccountCredential = _
    private var service: YouTube = _
  
    override def onCreate(savedInstanceState: Bundle): Unit = {
      super.onCreate(savedInstanceState)
  
      val prefs = getPreferences(Context.MODE_PRIVATE)
      credential = GoogleAccountCredential.usingOAuth2(this, List(YouTubeScopes.YOUTUBE_READONLY))
      credential.setSelectedAccountName(prefs.getString(PrefAccountName, None.orNull))
  
      val transport = new NetHttpTransport()
      val factory =  new JacksonFactory()
  
      service = new YouTube.Builder(transport, factory, credential)
        .setApplicationName(getString(R.string.app_name))
        .setYouTubeRequestInitializer(new YouTubeRequestInitializer(ApiKey)) // &lt;-- (1)
        .build()
    }
  
    /*
    check for Google Play Service
  
    choose account
     */
  
    private def onAccountChooseOk(accountName: String): Unit = {
      credential.setSelectedAccountName(accountName)
  
      val prefs = getPreferences(Context.MODE_PRIVATE).edit()
      prefs.putString(PrefAccountName, accountName)
      prefs.commit()
  
      rxScalaRunInBackground(loadYoutubeChannels, onLoadYoutubeChannelsOk, onLoadYoutubeChannelsError)
    }
  
    private def loadYoutubeChannels(): ChannelListResponse = {
      val channelsQuery = service.channels().list("contentDetails")
      channelsQuery.setMine(true)
      channelsQuery.setMaxResults(50l)
      //channelsQuery.setKey(ApiKey)  // &lt;-- (2)
      channelsQuery.execute()
    }
  
    private def onLoadYoutubeChannelsError(e: Throwable): Unit = {
      Log.e(Tag, "onLoadYoutubeChannelsError", e)
  
      e match {
        case _: GooglePlayServicesAvailabilityIOException =&gt; // checkGooglePlayServicesAvailable()
        case e: UserRecoverableAuthIOException =&gt; // startActivityForResult(e.getIntent, RequestAuthorization);
        case _ =&gt; finish()
      }
    }
  
    private def onLoadYoutubeChannelsOk(response: ChannelListResponse): Unit = {
      Log.e(Tag, s"onLoadYoutubeChannelsOk: $response")
    }
  
  }
  
  object YotubeTestActivity {
  
    private val Tag = "YotubeTestActivity"    
    private val PrefAccountName = "accountName"    
    private val ApiKey = "API_KAY_FROM_DEV_CONSOLE"
  
  }
  </code></pre>
  
  <p>When i do not use <em>ApiKey</em>, i mean when <strong>(1)</strong> and <strong>(2)</strong> is commented, i get this error:</p>
  
  <pre><code>{
    "code" : 403,
    "errors" : [ {
      "domain" : "usageLimits",
      "message" : "Access Not Configured. YouTube Data API has not been used in project 608941808256 bef$re or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube/overview?project=608941808256 then r$try. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
      "reason" : "accessNotConfigured",
      "extendedHelp" : "https://console.developers.google.com/apis/api/youtube/overview?project=60894180$256"
    } ],
    "message" : "Access Not Configured. YouTube Data API has not been used in project 608941808256 befor$ or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube/overview?project=608941808256 then ret$y. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
  }
  </code></pre>
  
  <p>When i use <em>browser key</em> or <a href="https://developers.google.com/youtube/registering_an_application#create_project" rel="nofollow noreferrer">api key</a>, i get this error:</p>
  
  <pre><code>{
    "code" : 401,
    "errors" : [ {
      "domain" : "global",
      "location" : "Authorization",
      "locationType" : "header",
      "message" : "Invalid Credentials",
      "reason" : "authError"
    } ],
    "message" : "Invalid Credentials"
  }
  </code></pre>
  
  <p>As far as i understood <em>yt-direct-lite-android</em> use <em>ApiKey</em> only in <em>YouTubePlayerFragment</em>, but not when fetching some youtube data (channels, etc). So.. it's unfair.</p>
  
  <p>Can someone tell what i'm doing wrong? Thanks.</p>