Module: Yt::Associations::Authentications
- Included in:
- Models::Account
- Defined in:
- lib/yt/associations/authentications.rb
Overview
Provides authentication methods to YouTube resources, which allows to access to content detail set-specific methods like ‘access_token`. YouTube resources with authentication are: accounts.
Instance Method Summary collapse
- #auth ⇒ Object
- #authentication ⇒ Object
- #authentication_url ⇒ Object
- #initialize(options = {}) ⇒ Object
-
#refresh ⇒ Object
Obtains a new access token.
Instance Method Details
#auth ⇒ Object
23 24 25 |
# File 'lib/yt/associations/authentications.rb', line 23 def auth self end |
#authentication ⇒ Object
27 28 29 30 |
# File 'lib/yt/associations/authentications.rb', line 27 def authentication @authentication = current_authentication @authentication ||= new_authentication || refreshed_authentication! end |
#authentication_url ⇒ Object
32 33 34 35 36 37 |
# File 'lib/yt/associations/authentications.rb', line 32 def authentication_url host = 'accounts.google.com' path = '/o/oauth2/auth' query = authentication_url_params.to_param URI::HTTPS.build(host: host, path: path, query: query).to_s end |
#initialize(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/yt/associations/authentications.rb', line 14 def initialize( = {}) @access_token = [:access_token] @refresh_token = [:refresh_token] @expires_at = [:expires_at] @authorization_code = [:authorization_code] @redirect_uri = [:redirect_uri] @scopes = [:scopes] end |
#refresh ⇒ Object
Obtains a new access token. Returns true if the new access token is different from the previous one
41 42 43 44 45 |
# File 'lib/yt/associations/authentications.rb', line 41 def refresh old_access_token = authentication.access_token @authentication = @access_token = @refreshed_authentications = nil old_access_token != authentication.access_token end |