title: Google API Ruby Client - single user with OAuth 2.0
body: <p>the goal is to have one Google (YouTube) account for the web app. Users of the web app will be able to upload videos via this account to the one YouTube channel. After many hours im in the ends. I've found plenty of samples how to implement for Google user &lt;-> web app interaction, but I don't need such comprehensive solution.</p>
  
  <p>I'm trying over OAuth 2.0 (as recommended) and with Google API Ruby Client (<a href="https://github.com/google/google-api-ruby-client" rel="nofollow">https://github.com/google/google-api-ruby-client</a>)</p>
  
  <p>So far I have authorized the Google account (which will have that YouTube channel) with the web app, all necessary scopes included, offline access too and I have mechanism for refreshing access token. So I have access token, refresh token, client id and client secret.</p>
  
  <p>But I don't know how to send a simple authorized request. The result below returns me "Daily Limit for Unauthenticated Use Exceeded." after a while so something wrong - i guess im missing part with client id and client secret. </p>
  
  <p>So the question is: How to send simply authorized request via OAuth 2.0 with Google API Ruby Client, when we work with only one user and we have all necessary ids, secrets and tokens?</p>
  
  <p>Thanks for any help or suggestion.</p>
  
  <pre class="lang-rb prettyprint-override"><code># Faraday connection
  conn = Faraday.new(:url =&gt; 'https://accounts.google.com',:ssl =&gt; {:verify =&gt; false}) do |faraday|
    faraday.request  :url_encoded
    faraday.response :logger
    faraday.adapter  Faraday.default_adapter
  end    
  
  # Refresh token
  result = conn.post '/o/oauth2/token', {
    'refresh_token' =&gt; "1/1lDIvifN******************dk9Akuc9ELVKM0",
    'client_id' =&gt; "61********506.apps.googleusercontent.com",
    'client_secret' =&gt; "********************g_dLfKmi",
    'grant_type' =&gt; 'refresh_token'}
  
  @output = ActiveSupport::JSON.decode result.body
  @access_token = @output['access_token']   
  @token_type = @output['token_type'] 
  
  
  # Google Client
  client = Google::APIClient.new      
  
  # YouTube API v3
  api = client.discovered_api('youtube', 'v3')
  
  # Retrieve list of playlists (not working)
  @result = client.execute(
    :api_method =&gt; api.playlists.list,
    :parameters =&gt; {'part' =&gt; 'snippet', 'mine' =&gt; 'true'},
    :authorization =&gt; {'token_type' =&gt; @token_type, 'access_token' =&gt; @access_token}
  )
  </code></pre>