简体   繁体   中英

gem 'omniauth-stripe-connect'-Authentication failure, invalid_credentials, invalid_grant

In my view:

<form action="/users/auth/stripe_connect">
    <input type="hidden" name="response_type" value="code" />
    <input type="hidden" name="client_id" value="<%= STRIPE_CLIENT_ID %>" />
    <input type="hidden" name="scope" value="read_write" />
    <input type="hidden" name="stripe_user[product_category]" value="charity" />
    <input type="text" placeholder="Enter Amount" name="state">
    <input class="btn green search_button" type="submit" value="Donate" />
</form>

In my development.rb:

STRIPE_CLIENT_ID = 'my client id' STRIPE_SECRET = 'my client secret'

In my omniauth_callbacks_controller:

def stripe_connect
    # Delete the code inside of this method and write your own.
    # The code below is to show you where to access the data.
    raise request.env["omniauth.auth"].to_yaml
  end

In my routes.rb

devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks" }

In my config/initializers/omniauth.rb:

 Rails.application.config.middleware.use OmniAuth::Builder do
     provider :stripe_connect, STRIPE_CLIENT_ID, STRIPE_SECRET
  end

In my devise.rb

config.omniauth :stripe_connect,
    STRIPE_CLIENT_ID,
    STRIPE_SECRET,
    :scope => 'read_write', # or :scope => 'read_only'
    :stripe_landing => 'login

on submitting the form i am redirecting to https://connect.stripe.com/oauth/authorize but then i am receiving the error on my console

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." }

I already already registered my app on stripe. Thanks in advance.

If you are using devise to specify your connection details, then you don't also need to specify them in omniauth.rb or development.rb. You only need to include your client id and secret once.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM