Module: Yandex::Webmaster::Authorization

Included in:
Base
Defined in:
lib/yandex-webmaster/authorization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scopesObject

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_codeObject

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(authorization_code, params = {})
  self.configuration.oauth_token = (self.token(authorization_code, params).token)
  self
end

#authenticated?Boolean

Check whether authentication credentials are present

Returns:

  • (Boolean)


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 authorize_url(params = {})
  self.verify_oauth!
  self.oauth.auth_code.authorize_url(params)
end

#oauthObject

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(authorization_code, params = {})
  self.verify_oauth!
  self.oauth.auth_code.get_token(authorization_code, params)
end