Doorkeeper with Rails and Zapier

I set up Oauth2 authentication with Zapier for Seviipay.com recently and figured it was worth a short post on the gotchas I encountered.

The biggest problem I had was with the Refresh token configuration. I would do a test connection, validate that I wanted to give Zapier access, send a test notification and it would work. Then an hour later I get an email from Zapier that they got a 401 error and are turning off my integration. The issues were that Doorkeeper does not enable refresh tokens by default and that Zapier does not pass the client ID or secret by default to the refresh api.

Below is my doorkeeper.rb with all comments removed. I had to uncomment the line for use_refresh_token.


Doorkeeper.configure do
  orm :active_record

  resource_owner_authenticator do
       current_user || warden.authenticate!(scope: :user)
  end

  admin_authenticator do |_routes|
    current_user || warden.authenticate!(scope: :user)
  end

  access_token_expires_in 2.hours
  use_refresh_token
end


Then in Zapier I just had to update my request options to include the client id and client secret.

One other issue I ran into is that Doorkeeper requires you to set a SCOPE. I just put the string ‘READ’ in for my scope and it seems to be working.

Leave a Reply

Your email address will not be published. Required fields are marked *