isaacsanders / omniauth-stripe-connect

Stripe Connect OAuth2 Strategy for OmniAuth 1.0
MIT License
130 stars 74 forks source link

error/solved: This authorization code has already been used #27

Closed markaharper closed 9 years ago

markaharper commented 9 years ago

First off - Thank you for the gem - fantastic!

error/solved

When following your exact instructions I receive an error

"Could not authenticate you from StripeConnect because "Invalid credentials"."

With the log files (below), I noticed a two consecutive calls:

omniauth: (stripe_connect) Callback phase initiated. omniauth: (stripe_connect) Callback phase initiated.

To solve this I removed from the OmniAuth::Builder from initializer omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do provider :stripe_connect, CONFIG[:stripe_connect_client_id], CONFIG[:stripe_secret_key] end

Worked - Weird.

Rails 4.2 - Ruby 2.0 - Devise 3.2.4

GEMFILE:

gem 'devise' gem 'oauth2' gem 'omniauth-stripe-connect' gem 'stripe' gem 'stripe_event'

So maybe the other gems are causing the conflict.

Again removing the omniauth.rb file solved the double callback problem. Weird.

Again, thank you for this gem - really really helped.

To Your Success!

Mark

P.S. as a sidenote - in your readme.md at the top if you could clarify the steps prior adding this gem: devise with :omniauthable set on the User model.

Helpful to me was: Railscasts

Stripe http://railscasts.com/episodes/288-billing-with-stripe

Devise with Omniauth http://railscasts.com/episodes/235-devise-and-omniauth-revised

YAML for security http://railscasts.com/episodes/85-yaml-configuration-revised

LOG FILES:

Started GET "/users/auth/stripe_connect/callback?state=302f09d9d25d25e4a100947957999687521145fa3e6ea696&scope=read_only&code=ac_4xdmF7OS0XP1yk8VkOIal9b46vc1STGg" for 127.0.0.1 at 2014-10-15 06:31:13 +0300 I, [2014-10-15T06:31:13.569651 #1924] INFO -- omniauth: (stripe_connect) Callback phase initiated. I, [2014-10-15T06:31:14.799390 #1924] INFO -- omniauth: (stripe_connect) Callback phase initiated. E, [2014-10-15T06:31:15.966771 #1924] ERROR -- omniauth: (stripe_connect) Authentication failure! invalid_credentials: OAuth2::Error, invalid_grant: This authorization code has already been used. All tokens issued with this code have been revoked. { "error": "invalid_grant", "error_description": "This authorization code has already been used. All tokens issued with this code have been revoked." }

loureirorg commented 9 years ago

Thank you very much!

isaacsanders commented 9 years ago

?

loureirorg commented 9 years ago

Hi @isaacsanders , I followed the README instructions and I got this error: "error/solved: This authorization code has already been used". So I googled and reached here. I removed my omniauth.rb initializer and the error was gone. So, I was thanking @markaharper for provide me a solution.

timeshiftseiya commented 7 years ago

@loureirorg thx

SophiaPetrova commented 7 years ago

@markaharper Thanks!