【发布时间】: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