Facebook Login :Can't Load URL The domain of this URL isn't included in the app's domains

31,944

Solution 1

I want to share 2 ways for making solution. Hope it will solve your issue.

Solution 1:

Facebook now roles some features as plugins. In the left hand side select Products and add product. Then select Facbook Login. Pretty straight forward from there, you'll see all the Oauth options show up.

OR,

Select Products and add product. Then select Facbook Login.

Then added http://localhost:3000/ to the field 'Valid OAuth redirect URIs', and then everything worked.

Solution-2:

It usually happens if you have entered the wrong details when you created the App in Facebook. Or have you changed a URL's of an existing App?

Can you please recheck the settings of your APP in this page?

https://developers.facebook.com/apps

  1. Select the correct App and click in the edit button;
  2. Check the URLs & paths are correctly entered and are pointing to the site where you have installed Ultimate Facebook plugin.

Credit goes to Lei lionel

UPDATE1:

I think your access token already expires. So you need to extend access token. For this, please go through this link:

  1. Extend Facebook access token (make it 60days last)
  2. Expiration and Extension of Access Tokens

Resource Link:

  1. Generate "never-expire" access token for Facebook Page
  2. Do Facebook Oauth 2.0 Access Tokens Expire?

UPDATE2:

I just want to ask 1 thing more is it possible the app domain error has smthng to do with access token expiration time?

Ans:

Generating Long-Lived User Tokens from Server-Side Long-Lived Tokens

Facebook has an advanced option for obtaining long-lived access tokens for apps that:

  1. Have their own authentication system (using a username/password for example)
  2. Store, on their servers, a Facebook access token for people using it that they send to different clients (browser or native mobile apps)
  3. Make API calls from all of those clients

If your app is set up like this it should use the process described here to obtain an access token from each client to avoid triggering Facebook's automated spam systems. The end result will be that each client will have its own long-lived access token.

At a high level, this is how you can obtain a long-lived token from the client:

  1. Make a call to Facebook's server from your server using a valid and current long-lived token to generate a code. (This assumes you've already obtained a long-lived token via Facebook Login. If the token you're using is invalid or expired, you'll have to obtain a new one by making the person using your app log in again.)
  2. Securely send that code to the client.
  3. The client then exchanges the code for a long-lived token.
  4. The client can use the long-lived token to post stories or query data.

Getting the code

Using a long-lived user access token, make a call to the following endpoint:

https://graph.facebook.com/oauth/client_code?access_token=...&client_secret=...&redirect_uri=...&client_id=...

You need to give input: access_token, client_secret, redirect_uri and client_id.

Response will be:

The response will look something like:

{"code": "...."}

Redeeming the code for an access token

Once you've retrieved the code from Facebook's server you then need to ship it to the client via a secure channel. Once that's done, you need to make a request from the client to this endpoint:

https://graph.facebook.com/oauth/access_token?code=...&client_id=...&redirect_uri=...&machine_id= ...

The call requires the following arguments:

client_id - Yes

code - Yes

redirect_uri - Yes

machine_id - No

The response will look like:

{"access_token":"...", "expires_in":..., "machine_id":"..."}

Solution 2

I had such trouble because in the oauth redirection URL I only put : - http://example.com/#/redirect-url whereas I also had to put : - http://example.com

Even if I only want to redirect to /#/redirect-url. Maybe the ajax sites cause troubles.

Share:
31,944
Vartika
Author by

Vartika

Working on gwt-java ,nosql databases like couchdb and neo4j from more than 3 years. Worked on couchbase. Currently working on Neo4j.

Updated on March 22, 2020

Comments

  • Vartika
    Vartika about 4 years

    I know many such questions have already been asked tried a lot then after posting the question. My Problem is still unresolved.

    I have a web application where I embedded the Facebook login using Oauth Authentication. I used the following code for help Facebook login with Java

    Till last month it was working fine but from few days we are coninuously getting the Error : -

    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 subdomains of your app to the App Domains field in your app settings.

    **Setting used are following:-
      Website url : **https://www.enggheads.com/**
      App Domain   :  **enggheads.com**
       Redirect uri : 
          1. https://www.enggheads.com/#!login
          2. https://www.enggheads.com/#!signup**
    

    SCREENSHOTS:

    DashBoard

    Basic Setting Of App

    Fblogin setting added from add product on right panel

    So, I just want to know whats the issue why I am facing this problem. Is there something which I am missing in the settings section?

    UPDATE

    Code flows :

    Step1. On button click url called--->

    "http://www.facebook.com/dialog/oauth?" + "client_id="
                        + FB_APP_ID + "&redirect_uri="
                        + URLEncoder.encode(REDIRECT_URI, "UTF-8")
                        + "&scope=public_profile ";
    

    I am receiving error on this very part where it gives error 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 subdomains of your app to the App Domains field in your app settings.

  • Vartika
    Vartika almost 8 years
    So nice of you to answer.Check My setting on the app. i am again editing it in the question.
  • Vartika
    Vartika almost 8 years
  • SkyWalker
    SkyWalker almost 8 years
    @Vartika I think your access token already expires. Please have a look UPDATED1 portion.
  • Vartika
    Vartika almost 8 years
    Sir, but how can this problem generated by itself? As it was working perfectly ok from last 2 months. Still I will look into the issue. I just want to ask 1 thing more is it possible the app domain error has smthng to do with access token expiration time?
  • SkyWalker
    SkyWalker almost 8 years
    Native mobile apps using Facebook's SDKs will get long-lived access tokens, good for about 60 days. These tokens will be refreshed once per day when the person using your app makes a request to Facebook's servers. If no requests are made, the token will expire after about 60 days and the person will have to go through the login flow again to get a new token. @Vartika
  • Vartika
    Vartika almost 8 years
    I didnt reach to their where i will get code and exchange it for access token. Sorry sir, May be i am unable to making you understand my problem. But , please request you to try to understand it patiently... The problem comes when we go to the login url of facebook where we go with all he credentials
  • SkyWalker
    SkyWalker almost 8 years
  • Vartika
    Vartika almost 8 years
    THere was no issue related to acces token. i read the document properly of acces token. We are using the safe way. ISSUE :--- redirect uri . Don't know why but the uri is not taking the hash toke of our urls. you must have noticed it in our redirect uri I have given in the ques like #!login etc... On the testing project I have done its working perfect both for javascript nd java code. Hope it will work ok on our production mode project. Thanks
  • SkyWalker
    SkyWalker almost 8 years
    @Vartika Thanks for sharing
  • AesSedai101
    AesSedai101 over 6 years
    Welcome to StackOverflow! Please have a look at the guide on how to write a good answer