jeudi 30 avril 2015

Stripe Connect OAuth/Devise integration with Rails: "No application matches the supplied client identifier"

I'm trying to integrate Stripe OAuth in a Rails application w/ Devise using this tutorial. I think I've followed it to a t, but I'm receiving this error when I go to Connect to Stripe on my app.

{"error":{"message":"No application matches the supplied client identifier"}}

I'm not sure how to check whether the client identifier I declare in my application.yml is even being passed in, or what value it's reading. Here's my setup so far:

config/application.yml (has my IDs from Stripe account - I edited them out here):

STRIPE_CONNECT_CLIENT_ID: "____________"
STRIPE_SECRET_KEY: "_____________"

config/initializers/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

config/routes.rb

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

controllers/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) %>

Aucun commentaire:

Enregistrer un commentaire