【问题标题】:gem 'omniauth-stripe-connect'-Authentication failure, invalid_credentials, invalid_grantgem 'omniauth-stripe-connect'-身份验证失败,invalid_credentials,invalid_grant
【发布时间】:2014-08-25 23:23:39
【问题描述】:

在我看来:

<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>

在我的 development.rb 中:

STRIPE_CLIENT_ID = '我的客户 ID' STRIPE_SECRET = '我的客户密码'

在我的 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

在我的 routes.rb 中

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

在我的 config/initializers/omniauth.rb 中:

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

在我的 devise.rb 中

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

在提交表单时,我将重定向到https://connect.stripe.com/oauth/authorize,但随后我在控制台上收到错误消息

身份验证失败! invalid_credentials: OAuth2::Error, invalid_grant: 此授权码已被使用。使用此代码发行的所有令牌都已被撤销。 { “错误”:“invalid_grant”, "error_description": "此授权码已被使用。使用此码发布的所有令牌均已被撤销。" }

我已经在 Stripe 上注册了我的应用。 提前致谢。

【问题讨论】:

    标签: ruby-on-rails


    【解决方案1】:

    如果您使用 devise 来指定您的连接详细信息,那么您也不需要在 omniauth.rb 或 development.rb 中指定它们。您只需要包含您的客户 ID 和密码一次。

    【讨论】:

    • 能否请您提及一次在何处包含 client_id 和 secret。究竟是哪个文件?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-27
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多