Class: Yt::Account
Overview
Provides methods to access a YouTube account.
Instance Method Summary collapse
- #access_token_for(scope) ⇒ Object
- #auth ⇒ Object
-
#initialize(options = {}) ⇒ Account
constructor
A new instance of Account.
Methods included from Associations
Methods included from Yt::Actions::Update
Constructor Details
#initialize(options = {}) ⇒ Account
Returns a new instance of Account.
12 13 14 15 16 17 18 |
# File 'lib/yt/models/account.rb', line 12 def initialize( = {}) # By default is someone passes a refresh_token but not a scope, we can assume it's a youtube one @scope = .fetch :scope, 'https://www.googleapis.com/auth/youtube' @access_token = [:access_token] @refresh_token = [:refresh_token] @redirect_url = [:redirect_url] end |
Instance Method Details
#access_token_for(scope) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/yt/models/account.rb', line 20 def access_token_for(scope) # TODO incremental scope # HERE manage the fact that we must change some scope on device, # like 'https://www.googleapis.com/auth/youtube.readonly' is not accepted if Yt.configuration.scenario == :device_app && scope == 'https://www.googleapis.com/auth/youtube.readonly' scope = 'https://www.googleapis.com/auth/youtube' end # TODO !! include? is not enough, because (for instance) 'youtube' also includes 'youtube.readonly' # unless (@scope == scope) || (scope == 'https://www.googleapis.com/auth/youtube.readonly' && @scope =='https://www.googleapis.com/auth/youtube') # @scope = scope # @access_token = @refresh_token = nil # end @access_token ||= refresh_access_token || get_access_token end |
#auth ⇒ Object
38 39 40 |
# File 'lib/yt/models/account.rb', line 38 def auth self end |