Class: Myoack::OAuth2Config

Inherits:
KeyConfig show all
Defined in:
lib/myoack/key_config.rb

Direct Known Subclasses

GitHubConfig

Instance Attribute Summary collapse

Attributes inherited from KeyConfig

#config, #id, #type

Instance Method Summary collapse

Methods inherited from KeyConfig

config_defaults, default, id, #initialize, type

Constructor Details

This class inherits a constructor from Myoack::KeyConfig

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



161
162
163
# File 'lib/myoack/key_config.rb', line 161

def access_token
  @access_token
end

#access_token_urlObject

Optional Example: “github.com/login/oauth/access_tokenDefault: “#@site/oauth/access_token”



132
133
134
# File 'lib/myoack/key_config.rb', line 132

def access_token_url
  @access_token_url
end

#authorize_urlObject

Optional Example: “github.com/login/oauth/authorizeDefault: “#@site/oauth/authorize”



124
125
126
# File 'lib/myoack/key_config.rb', line 124

def authorize_url
  @authorize_url
end

#client_idObject

Returns the value of attribute client_id.



159
160
161
# File 'lib/myoack/key_config.rb', line 159

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



160
161
162
# File 'lib/myoack/key_config.rb', line 160

def client_secret
  @client_secret
end

#siteObject

Required Example: “github.com/login



119
120
121
# File 'lib/myoack/key_config.rb', line 119

def site
  @site
end

Instance Method Details

#authorize!Object



137
138
139
140
# File 'lib/myoack/key_config.rb', line 137

def authorize!
  url = "http://%s:%s/oauth2/authorize?id=#{id}" % [LocalAuthorization::HOST, LocalAuthorization::PORT]
  `open "#{url}"`
end

#saveObject



142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/myoack/key_config.rb', line 142

def save
  cfg = config.load_keys_file
  cfg[id] = {
    'site' => site,
    'authorize_url' => authorize_url,
    'access_token_url' => access_token_url,
    'client_id' => client_id,
    'client_secret' => client_secret,
    'access_token' => access_token
  }
  config.dump_config_file cfg
end

#save!Object



155
156
157
# File 'lib/myoack/key_config.rb', line 155

def save!
  save
end