Sha256: 6d66da2ea7bc4d5847248e9316bbfa21e167de1ef9b9ffa86853a701af71c400
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
require 'omniauth/oauth' require 'multi_json' module OmniAuth module Strategies class Mailchimp < OmniAuth::Strategies::OAuth2 def initialize(app, client_id=nil, client_secret=nil, options={}, &block) client_options = { :authorize_url => 'https://login.mailchimp.com/oauth2/authorize', :token_url => 'https://login.mailchimp.com/oauth2/token', } super(app, :mailchimp, client_id, client_secret, client_options, options, &block) end def auth_hash data = user_data OmniAuth::Utils.deep_merge( super, { 'uid' => @access_token.client.id, 'extra'=> { 'user_hash' => data } } ) end 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.3.2 | lib/omniauth/strategies/oauth2/mailchimp.rb |
oa-oauth-0.3.0 | lib/omniauth/strategies/oauth2/mailchimp.rb |
oa-oauth-0.3.0.rc3 | lib/omniauth/strategies/oauth2/mailchimp.rb |