Search code examples
ruby-on-railsauthenticationstripe-connect

Stripe Connect Authentication failure - invalid_client: No such API key: Bearer


I'm working on Ruby on Rails with the OmniAuth-StripeConnect Gem, and every time I try to connect to the Stripe Connect API I get this failure in authentication, 'redirecting' me to the failure method of the Omniauth callback controller :

E, [2018-05-28T13:41:50.435158 #58778] ERROR -- omniauth (stripe_connect) Authentication failure! invalid_credentials: OAuth2::Error, invalid_client: No such API key: Bearer
{
  "error": "invalid_client",
  "error_description": "No such API key: Bearer"
}

I found in the doc that an error of invalid_client meant either one of these :
https://stripe.com/docs/connect/oauth-reference#post-deauthorize-error-codes

  • client_id does not belong to you
  • stripe_user_id does not exist or is not connect to your application
  • API key mode (live or test mode) does not match the client_id mode

But i doubled checked and it's none of these.

Does anyone has an idea ?


Solution

  • Old question, I know but I came across this error today, too and it may help others in future. The owner of the repo/gem said that he wasn't "really supporting" it anymore, anyway. This answer assumes you're trying to get a user to create their account on Stripe and pass an auth token back to your controller.

    I decided to skip using the gem altogether. After 'undoing' the installation instructions, I found that keeping the stripe_connect method under the OmniauthCallbacksController still worked as you'd expect - you just don't get the error described as above.

    According to the Stripe Connect docs (https://stripe.com/docs/connect/standard-accounts#redirected), if you don't receive an error code, then the request was successful. You should receive an authorization code inside the response which can be used to access that user's Stripe account via their API. You'll only have five minutes to use that token before it expires. I imagine you'll need to start the whole process over again if you miss it.

    Hope this helps.