Omniauth-facebook Rails 6: Invalid App ID

619 views Asked by At

I am using Rails 6.0.0, Devise 4.7.1, and , omniauth-facebook 5.0.0.

  • I was able to get omniauth to work successfully with twitter via omniauth-twitter (which I notice currently happens to use oauth 1.0 as opposed to oauth 2.0).
  • I was also able to get omniauth to work successfully with google via omniauth-google-oauth2 which uses oauth 2.0.
  • I am not having the same luck with omniauth-facebook (which happens to use oauth 2.0).

The initalizers/devise.rb file is where the main config is in order to specify the provider and then the app_id and app_secret for each provider. Here is what I have (of course with a placeholder for the real app_id and secret):

config.omniauth :facebook, "my-app-id", "my-app-secret-key", scope: "email"
config.omniauth :twitter, "my-app-id", "my-key"
config.omniauth :google_oauth2, "my-client-id", "my-client-seceret"

Again, it works just fine with twitter and google. But when I click the "Sign in With Facebook" link it shows this on facebook:

invalid app id

I am stumped because I know I entered the app ID correctly. The status of the app is "Live" as opposed to "Development (which required me to provide a Privacy Policy URL).

Since omniauth-twitter works, it makes me wonder if something is wrong on the provider end (facebook) or perhaps there is something wrong with the omniauth-facebook gem? Of course: I will never rule out that I am missing something obvious.

I am using https for my app (https now appears to be a requirement in order to use this service from facebook), so that isn't the issue either.

1

There are 1 answers

0
Felipe Cruz On

I was able to solve this by simply changing:

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :facebook, ENV['APP ID'], ENV['APP SECRET']
end 

to

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :facebook, 'APP ID','APP SECRET'
end