simi / omniauth-facebook

Facebook OAuth2 Strategy for OmniAuth
https://simi.github.io/omniauth-facebook/
1.26k stars 403 forks source link

Authentication failure! invalid_credentials: OAuth2::Error, : {"error":{"message":"Can't load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and sub-domains of your app to the App Domains field in your app settings." #371

Closed mrabro closed 2 years ago

mrabro commented 2 years ago

Hello, I have been trying to integrate social login to my app, But stucked in nowhere....

my gem file:

gem 'omniauth-facebook', '4.0.0'
gem "omniauth", "1.6.1"

devise.rb config.omniauth :facebook, "APP_ID", "APP_SECRET", token_params: { parse: :json }

user model: devise :omniauthable, omniauth_providers: %i[facebook]

and then adding link to view link_to "Register with Facebook", user_facebook_omniauth_authorize_path, method: :post

but whenever clicking on the link, taking me to facebook, asking to login via FB, and when fb user login is done, it takes back me to failure callback stating below msgs in the log..

| I, [2022-01-24 07:25:18 #1]  INFO -- : Started GET "/api/v1/users/auth/facebook" for 172.20.0.1 at 2022-01-24 07:25:18 +0000
| I, [2022-01-24T07:25:18.819844 #1]  INFO -- omniauth: (facebook) Request phase initiated.
| I, [2022-01-24 07:25:19 #1]  INFO -- : Started GET "/api/v1/users/auth/facebook/callback?code=AQAdlPKadQWhYftuherICQIXGHuIhLVzPdJbkWpkbIZZg8RiE3rBY_D-fj6kYApPP35HzfGrnQJRWTEs3i_ahz2ko9MhwqkM1QfMF6IeWCmqTJEQWwAekzAuOsJf6dpu11MUrC3gIgQ9AL6qEHIY5Vvkrh1B2QzoXMeaKw9LuSsRzrJQAxbQosh3rcBVQ1NEp2gRk623GRGQKsMe0w7_8jsskdfsdfsfsfdRC4BzcsP1eGOzbjy8AA1j7wcOuTph78u220fxqnTkRiINGGQxHsjpgzOoe398I8UTiTS8U1pr1HO_5F44kaURwShZXnks6ZCUU8jIaIlfLh46mBIw_QR89XO2U16mIpGNoeZef1D_0Q-Ye3sI-wodQCMHH3kBVKspgG2K0oISniOQ&state=9812578bbd720814fd856fd874f3fd23383a284ea1d7b1ba" for 172.20.0.1 at 2022-01-24 07:25:19 +0000
| I, [2022-01-24T07:25:19.817653 #1]  INFO -- omniauth: (facebook) Callback phase initiated.
| E, [2022-01-24T07:25:20.207281 #1] ERROR -- omniauth: (facebook) Authentication failure! invalid_credentials: OAuth2::Error, {"message"=>"URL لوڈ نہیں کیا جا سکتا: اس URL کی ڈومین ایپ کی ڈومینز میں شامل نہیں ہے۔ یہ URL لوڈ کرنے کا اہل ہونے کیلئے، اپنی ایپ کی تمام ڈومینز اور ذیلی ڈومینز کو اپنی ایپ کی سیٹنگز کی ایپ ڈومینز فیلڈ میں شامل کریں۔", "type"=>"OAuthException", "code"=>191, "fbtrace_id"=>"AAGSW2l-gRCDYQE6p0qS6fI"}: 
| {"error":{"message":"URL \u0644\u0648\u0688 \u0646\u06c1\u06cc\u06ba \u06a9\u06cc\u0627 \u062c\u0627 \u0633\u06a9\u062a\u0627: \u0627\u0633 URL \u06a9\u06cc \u0688\u0648\u0645\u06cc\u0646 \u0627\u06cc\u067e \u06a9\u06cc \u0688\u0648\u0645\u06cc\u0646\u0632 \u0645\u06cc\u06ba \u0634\u0627\u0645\u0644 \u0646\u06c1\u06cc\u06ba \u06c1\u06d2\u06d4 \u06cc\u06c1 URL \u0644\u0648\u0688 \u06a9\u0631\u0646\u06d2 \u06a9\u0627 \u0627\u06c1\u0644 \u06c1\u0648\u0646\u06d2 \u06a9\u06cc\u0644\u0626\u06d2\u060c \u0627\u067e\u0646\u06cc \u0627\u06cc\u067e \u06a9\u06cc \u062a\u0645\u0627\u0645 \u0688\u0648\u0645\u06cc\u0646\u0632 \u0627\u0648\u0631 \u0630\u06cc\u0644\u06cc \u0688\u0648\u0645\u06cc\u0646\u0632 \u06a9\u0648 \u0627\u067e\u0646\u06cc \u0627\u06cc\u067e \u06a9\u06cc \u0633\u06cc\u0679\u0646\u06af\u0632 \u06a9\u06cc \u0627\u06cc\u067e \u0688\u0648\u0645\u06cc\u0646\u0632 \u0641\u06cc\u0644\u0688 \u0645\u06cc\u06ba \u0634\u0627\u0645\u0644 \u06a9\u0631\u06cc\u06ba\u06d4","type":"OAuthException","code":191,"fbtrace_id":"AAGSW2l-gRCDYQE6p0qS6fI"}}
| I, [2022-01-24 07:25:20 #1]  INFO -- : FAILURE CALLBACK
| I, [2022-01-24 07:25:20 #1]  INFO -- : Redirecting to /

Though I have verified my APPID n SECRET are fine, and correct... still giving me invalid credentials error... My FB APP is in development mode, so it's saying the localhost will automatically be redirected, so it's not necessary to add the localhost urls in the whitelist url callbacks ... and app domain is set to localhost too. Still I don't understand what's wrong and where I have done wrong...

Please do suggest what should be done to get a proper resolution for this... I have been looking for this for a week, have tried many solutions posted in github issues or stackoverflow, have downgraded/upgraded gems for omniauth n fb... but still got no luck..

mrabro commented 2 years ago

I now updated the omniauth gems to their latest versions... now the current versions are:

  * oauth2 (1.4.7)
  * omniauth (2.0.4)
  * omniauth-facebook (9.0.0)
  * omniauth-oauth2 (1.7.2)

and now it's not showing in errors in the console log, but on the web page, saying Not found. Authentication passthru.

and check in the code it's entering in this block

def passthru
    Rails.logger.info "PASSTHRO METHOD"
    super
  end

I don't know what's happening here... what it does mean!

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.