【发布时间】:2018-04-19 07:45:30
【问题描述】:
我将 Rails 与 Devise 和 omniauth-stripe-connect gem 一起使用。
设计.rb
config.omniauth :stripe_connect,
ENV['STRIPE_CONNECT_CLIENT_ID'],
ENV['STRIPE_SECRET_KEY'],
:scope => 'read_write',
:stripe_landing => 'register'
Omniauth 回调控制器
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def stripe_connect
@user = current_user
if @user.update_attributes({
provider: request.env["omniauth.auth"].provider,
uid: request.env["omniauth.auth"].uid,
access_code: request.env["omniauth.auth"].credentials.token,
publishable_key: request.env["omniauth.auth"].info.stripe_publishable_key
})
# anything else you need to do in response..
sign_in_and_redirect @user, :event => :authentication
set_flash_message(:notice, :success, :kind => "Stripe") if is_navigational_format?
else
session["devise.stripe_connect_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
end
在开发中,这可以正常工作,并将我需要的信息添加给用户进行条带连接,但在生产中我遇到了这个错误。
{
2017-11-07T02:05:05.255495+00:00 app[web.1]: "error": "invalid_grant",
2017-11-07T02:05:05.255496+00:00 app[web.1]: "error_description": "Authorization code provided does not belong to you"
我在生产环境中设置了 live stripe api 密钥。我在想也许它与设计有关,但我真的不确定。
【问题讨论】:
-
您是否将应用中的
client_id替换为使用来自 dashboard.stripe.com/account/applications/settings 的生产 ID?
标签: javascript ruby-on-rails ruby devise stripe-connect