Class: Linkshare::Strategy
- Inherits:
-
OAuth2::Strategy::Base
- Object
- OAuth2::Strategy::Base
- Linkshare::Strategy
- Defined in:
- lib/linkshare/strategy.rb
Instance Method Summary collapse
-
#authorization(client_id, client_secret) ⇒ Object
Returns the Authorization header value for Basic Authentication.
-
#get_token(username, password, sid, params = {}, opts = {}) ⇒ Object
Retrieve an access token given the specified End User username, password and Linkshare AccountID.
Instance Method Details
#authorization(client_id, client_secret) ⇒ Object
Returns the Authorization header value for Basic Authentication
34 35 36 |
# File 'lib/linkshare/strategy.rb', line 34 def (client_id, client_secret) 'Basic ' + Base64.encode64(client_id + ':' + client_secret).gsub("\n", '') end |
#get_token(username, password, sid, params = {}, opts = {}) ⇒ Object
Retrieve an access token given the specified End User username, password and Linkshare AccountID.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/linkshare/strategy.rb', line 11 def get_token(username, password, sid, params = {}, opts = {}) request_body = opts.delete('auth_scheme') == 'request_body' params = {'grant_type' => 'password', 'username' => username, 'password' => password, 'scope' => sid }.merge(client_params).merge(params) params.merge!('client_params' => { :headers => { 'Authorization' => (client_params['client_id'], client_params['client_secret']), 'Accept' => 'application/xml'} }) # params.merge(:parse => :xml) @client.get_token(params, opts) end |