1

编辑:解决了这个问题。最终变得微不足道;我在编辑配置文件后忘记重新启动 Rails 服务器。

我正在尝试使用本教程将 Stripe OAuth 集成到带有设计的 Rails 应用程序中。我想我已经遵循它,但是当我在我的应用程序上连接到 Stripe 时收到此错误。

{"error":{"message":"没有应用程序匹配提供的客户端标识符"}}

我不确定如何检查我在 application.yml 中声明的客户端标识符是否被传入,或者它正在读取什么值。到目前为止,这是我的设置:

config/application.yml(有我来自 Stripe 帐户的 ID - 我在这里编辑了它们):

STRIPE_CONNECT_CLIENT_ID: "____________"
STRIPE_SECRET_KEY: "_____________"

配置/初始化程序/devise.rb

Devise.setup do |config|

config.omniauth :stripe_connect,
      ENV['STRIPE_CONNECT_CLIENT_ID'],
      ENV['STRIPE_SECRET_KEY'],
      :scope => 'read_write',
      :stripe_landing => 'register'

*other config code*

end

配置/路由.rb

Studiocracy::Application.routes.draw do
  devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks", registrations: 'registrations' }
*other stuff*
end

控制器/omniauth_callbacks_controller.rb

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

app/views/devise/registrations/edit.html.erb

<%= link_to image_tag('stripe.png'), user_omniauth_authorize_path(:stripe_connect) %>
4

2 回答 2

0

我犯了同样的愚蠢错误。后来我发现,这是因为我传递的客户 ID 错误。只需检查一次连接到条带按钮的href标签并重新检查。

于 2017-03-17T06:08:12.807 回答
0

/我通过在问号 ( ) 之前的主 URL 之后添加一个正斜杠 ( ) 得到了一个解决方案?

前:

https://connect.stripe.com/oauth/v2/authorize?scope=read_write&client_id={client_id}&redirect_uri={https//:example.com}
                                             v
https://connect.stripe.com/oauth/v2/authorize/?scope=read_write&client_id={client_id}&redirect_uri={https//:example.com}
                                             ^
于 2021-12-29T05:53:43.397 回答