Class: Tubeclip::AuthSubClient

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

Instance Method Summary collapse

Methods inherited from Client

#activity, #add_comment, #add_favorite, #add_playlist, #add_response, #add_video_to_playlist, #add_video_to_watchlater, #all_playlists, #captions_update, #comments, #current_user, #delete_comment, #delete_favorite, #delete_playlist, #delete_response, #delete_video_from_playlist, #delete_video_from_watchlater, #dislike_video, #enable_http_debugging, #favorites, #get_all_videos, #like_video, #message_delete, #my_contacts, #my_messages, #my_video, #my_videos, #new_subscription_videos, #playlist, #playlists, #profile, #profiles, #send_message, #subscribe_channel, #subscriptions, #unsubscribe_channel, #update_playlist, #update_position_video_from_playlist, #upload_token, #video_by, #video_by_user, #video_delete, #video_partial_update, #video_update, #video_upload, #videos, #videos_by, #watch_history, #watchlater

Methods included from Logging

#logger

Constructor Details

#initialize(*params) ⇒ AuthSubClient

Returns a new instance of AuthSubClient.



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/tubeclip/client.rb', line 336

def initialize *params
  puts "* AuthSubClient will be deprecated. Use OAuth2 Client."
  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] || "tubeclip"
    @legacy_debug_flag = hash_options[:debug]
  else
    puts "* warning: the method Tubeclip::AuthSubClient.new(token, dev_key) is deprecated, use Tubeclip::AuthSubClient.new(:token => 'token', :dev_key => 'dev_key')"
    @authsub_token              = params.shift
    @dev_key                    = params.shift
    @client_id                  = params.shift || "tubeclip"
    @legacy_debug_flag          = params.shift
  end
end

Instance Method Details

#create_session_tokenObject



353
354
355
356
357
358
359
360
361
# File 'lib/tubeclip/client.rb', line 353

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



363
364
365
366
367
368
369
370
371
# File 'lib/tubeclip/client.rb', line 363

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



373
374
375
376
377
378
379
380
381
# File 'lib/tubeclip/client.rb', line 373

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