Module: Yandex::Webmaster::Authorization
- Included in:
- Base
- Defined in:
- lib/yandex-webmaster/authorization.rb
Instance Attribute Summary collapse
-
#scopes ⇒ Object
Returns the value of attribute scopes.
Instance Method Summary collapse
-
#auth_code ⇒ Object
Strategy token.
- #authenticate(authorization_code, params = {}) ⇒ Object
-
#authenticated? ⇒ Boolean
Check whether authentication credentials are present.
-
#authorize_url(params = {}) ⇒ Object
Sends authorization request to Yandex.Webmaster.
-
#oauth ⇒ Object
Setup OAuth2 instance.
-
#token(authorization_code, params = {}) ⇒ Object
Makes request to token endpoint and retrieves access token value.
Instance Attribute Details
#scopes ⇒ Object
Returns the value of attribute scopes.
7 8 9 |
# File 'lib/yandex-webmaster/authorization.rb', line 7 def scopes @scopes end |
Instance Method Details
#auth_code ⇒ Object
Strategy token
23 24 25 26 |
# File 'lib/yandex-webmaster/authorization.rb', line 23 def auth_code self.verify_oauth! self.oauth.auth_code end |
#authenticate(authorization_code, params = {}) ⇒ Object
41 42 43 44 |
# File 'lib/yandex-webmaster/authorization.rb', line 41 def authenticate(, params = {}) self.configuration.oauth_token = (self.token(, params).token) self end |
#authenticated? ⇒ Boolean
Check whether authentication credentials are present
47 48 49 |
# File 'lib/yandex-webmaster/authorization.rb', line 47 def authenticated? self.configuration.oauth_token? end |
#authorize_url(params = {}) ⇒ Object
Sends authorization request to Yandex.Webmaster.
30 31 32 33 |
# File 'lib/yandex-webmaster/authorization.rb', line 30 def (params = {}) self.verify_oauth! self.oauth.auth_code.(params) end |
#oauth ⇒ Object
Setup OAuth2 instance
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/yandex-webmaster/authorization.rb', line 10 def oauth @client ||= ::OAuth2::Client.new(self.configuration.app_id, self.configuration.app_password, { :site => self.configuration.site || Yandex::Webmaster::Configuration.size, :authorize_url => '/authorize', :token_url => '/token', :ssl => { :verify => false } } ) end |
#token(authorization_code, params = {}) ⇒ Object
Makes request to token endpoint and retrieves access token value
36 37 38 39 |
# File 'lib/yandex-webmaster/authorization.rb', line 36 def token(, params = {}) self.verify_oauth! self.oauth.auth_code.get_token(, params) end |