lib/omniauth/strategies/stripe_connect.rb in omniauth-stripe-connect-2.2.0 vs lib/omniauth/strategies/stripe_connect.rb in omniauth-stripe-connect-2.3.0
- old
+ new
@@ -30,21 +30,41 @@
def raw_info
@raw_info ||= deep_symbolize(access_token.params)
end
+ def redirect_params
+ if options.key?(:callback_path) || OmniAuth.config.full_host
+ {:redirect_uri => callback_url}
+ else
+ {}
+ end
+ end
+
+ # NOTE: We call redirect_params AFTER super in these methods intentionally
+ # the OAuth2 strategy uses the authorize_params and token_params methods
+ # to set up some state for testing that we need in redirect_params
+
+ def authorize_params
+ params = super
+ params = params.merge(request.params) unless OmniAuth.config.test_mode
+ redirect_params.merge(params)
+ end
+
+ def token_params
+ params = super.to_hash(:symbolize_keys => true) \
+ .merge(:headers => { 'Authorization' => "Bearer #{client.secret}" })
+
+ redirect_params.merge(params)
+ end
+
def request_phase
- redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(authorize_params.merge(request.params)))
+ redirect client.auth_code.authorize_url(authorize_params)
end
def build_access_token
- headers = {
- :headers => {
- 'Authorization' => "Bearer #{client.secret}"
- }
- }
verifier = request.params['code']
- client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(token_params.to_hash(:symbolize_keys => true)).merge(headers))
+ client.auth_code.get_token(verifier, token_params)
end
end
end
end