Class: YouTubeIt::AuthSubClient

Inherits:
Client
  • Object
show all
Defined in:
lib/youtube_it/client.rb

Instance Method Summary collapse

Methods inherited from Client

#activity, #add_comment, #add_favorite, #add_playlist, #add_response, #add_video_to_playlist, #comments, #current_user, #delete_favorite, #delete_playlist, #delete_response, #delete_video_from_playlist, #dislike_video, #enable_http_debugging, #favorites, #like_video, #message_delete, #my_contacts, #my_messages, #my_video, #my_videos, #new_subscription_videos, #playlist, #playlists, #profile, #send_message, #subscribe_channel, #subscriptions, #unsubscribe_channel, #update_playlist, #upload_token, #video_by, #video_by_user, #video_delete, #video_update, #video_upload, #videos_by, #watch_history

Methods included from Logging

#logger

Constructor Details

#initialize(*params) ⇒ AuthSubClient

Returns a new instance of AuthSubClient.



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/youtube_it/client.rb', line 273

def initialize *params
  if params.first.is_a?(Hash)
    hash_options = params.first
    @authsub_token                 = hash_options[:token]
    @dev_key                       = hash_options[:dev_key]
    @client_id                     = hash_options[:client_id] || "youtube_it"
    @legacy_debug_flag             = hash_options[:debug]
  else
    puts "* warning: the method YouTubeIt::AuthSubClient.new(token, dev_key) is depricated, use YouTubeIt::AuthSubClient.new(:token => 'token', :dev_key => 'dev_key')"
    @authsub_token              = params.shift
    @dev_key                    = params.shift
    @client_id                  = params.shift || "youtube_it"
    @legacy_debug_flag          = params.shift
  end
end

Instance Method Details

#create_session_tokenObject



289
290
291
292
293
294
295
296
297
# File 'lib/youtube_it/client.rb', line 289

def create_session_token
  response = nil
  session_token_url = "/accounts/AuthSubSessionToken"

  http_connection do |session|
    response = session.get2('https://%s' % session_token_url,session_token_header).body
  end
  @authsub_token = response.sub('Token=','')
end

#revoke_session_tokenObject



299
300
301
302
303
304
305
306
307
# File 'lib/youtube_it/client.rb', line 299

def revoke_session_token
  response = nil
  session_token_url = "/accounts/AuthSubRevokeToken"

  http_connection do |session|
    response = session.get2('https://%s' % session_token_url,session_token_header).code
  end
  response.to_s == '200' ? true : false
end

#session_token_infoObject



309
310
311
312
313
314
315
316
317
# File 'lib/youtube_it/client.rb', line 309

def session_token_info
  response = nil
  session_token_url = "/accounts/AuthSubTokenInfo"

  http_connection do |session|
    response = session.get2('https://%s' % session_token_url,session_token_header)
  end
  {:code => response.code, :body => response.body }
end