Class: OmniAuth::Strategies::Mailchimp
- Defined in:
- lib/omniauth/strategies/oauth2/mailchimp.rb
Instance Attribute Summary
Attributes inherited from OAuth2
#client_id, #client_options, #client_secret, #options
Instance Method Summary collapse
- #auth_hash ⇒ Object
-
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Mailchimp
constructor
A new instance of Mailchimp.
- #user_data ⇒ Object
Methods inherited from OAuth2
Constructor Details
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Mailchimp
Returns a new instance of Mailchimp.
8 9 10 11 12 13 14 |
# File 'lib/omniauth/strategies/oauth2/mailchimp.rb', line 8 def initialize(app, client_id=nil, client_secret=nil, ={}, &block) = { :authorize_url => 'https://login.mailchimp.com/oauth2/authorize', :token_url => 'https://login.mailchimp.com/oauth2/token', } super(app, :mailchimp, client_id, client_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/omniauth/strategies/oauth2/mailchimp.rb', line 16 def auth_hash data = user_data OmniAuth::Utils.deep_merge( super, { 'uid' => @access_token.client.id, 'extra'=> { 'user_hash' => data } } ) end |
#user_data ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/omniauth/strategies/oauth2/mailchimp.rb', line 28 def user_data @data ||= MultiJson.decode(@access_token.get("https://login.mailchimp.com/oauth2/metadata").body) rescue ::OAuth2::Error => e if e.response.status == 302 @data ||= MultiJson.decode(@access_token.get(e.response.headers['location'])) else raise e end end |