Facebook authentication via AWS Cognito - facebook

I have an AWS Cognito User Pool set to federate authentication to Facebook and Google. It works fine with Google, not with Facebook.
When I click on "Continue with Facebook", the URL changes to "https://m.facebook.com" and the pages displays "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."
I find that puzzling because I believe I've properly configured the settings this error references.
Here's my app settings in facebook's developer console, the app domain is set. It has the format <domain prefix>.auth.<aws region>.amazoncognito.com to match the hosted UI of the AWS Cognito User Pool.
Here's my app's OAUTH settings in facebook's developer console. Note the URLs are the app domain prefixed with https:// and in one of the two URLs it's appended with oauth2/idresponse just in case, since Cognito seems to append that at least when it federates to Google.
This facebook app also has a website set in the FB developer console as follows:
I've followed AWS documentation for federating a Cognito User Pool to Facebook available here
The facebook app status is "Off: In Development". I assume that is acceptable, the app is not ready to be publicly available yet I need to be able to test authentication.

From the documentation https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-configuring-federation-with-social-idp.html. You should add Site URL as https://{your-user-pool-domain}/oauth2/idpresponse
Step 9: Under Website, type your user pool domain with the /oauth2/idpresponse endpoint into Site URL.
https://<your-user-pool-domain>/oauth2/idpresponse

Related

Webapp OAuth integration with the facebook spotify integration

We are facing an web application integration challenge that I could describe in great detail but an example is easier. We would like to link accounts of 2 very separate applications exactly how spotify accounts can be linked to facebook accounts. I'm not referring to how you can create a spotify account with a facebook login but linking your spotify account with a facebook account when separate accounts exist.
My understanding of OAuth is that the authorisation / authentication tokens are stored on the end user device (browser / cookies, app storage on mobile etc.) and that it is secure. It seems to me that spotify seems to be storing facebook authorisation tokens on their servers which seems to me to be a large security risk. The reason why I think this is that after I link my spotify account to my facebook account it is linked regardless of which client / device is used.
I have tried to find out in the internet how this works and have also inspect the browser application storage but cannot find out much information this way.

Facebook App management - what is the difference between App Domains (Basic) and Domain Manager (Advanced)

I have multiple subdomains using Facebook Login. I found that when adding a new subdomain, adding it into App Domains list in Basic page does not enable it. Adding the subdomain into Domain Manager in Advanced page makes it work.
so question 1: what is the difference between the 2?
In another question, it says that App Domain is supposed to be where the 'server side' files are located at.
background for question 2:
I have an API and a client that uses the same Facebook app. I assume that the api's URL should be in App Domain. But for the client, all the subdomains actually use the same codebase. I use AWS CloudFront to manage the HTTP requests from all subdomains and have them use code from the same S3 bucket. So essentially, the code is actually hosted in the s3 bucket which has 'Website Hosting' enabled.
question 2: should I just add the s3 bucket hosting URL, and ignore the subdomain URL's?
"App Domains" contain the domains and subdomains which can be used to perform Facebook Login, Share, Canvas etc on behalf of your app. Source, source.
In "Domain Manager" you add domains that will be allowed to prefetch content, for example when you Share of point Ads at a domain. Source.
If you're using Facebook Login, you also need to add "Valid Oauth Redirect URIs" under
Facebook Login / Settings as well.
Question 2: The page that makes the call to Facebook should be entered in App Domain (and possibly Domain Manager if you use Facebook Share.

Unable to Login to Facebook for Developers

I don't use Facebook, so I had to create an account in order to integrate a Facebook Login into our project. I setup the developer account and took down the App Id and App Secret. The response when I try to connect to Facebook currently is:
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.
So I would like to try updating the domains listed. However when I attempted to login I was prompted to provide a picture of myself (which I did) then given this message:
You Can't Log In Right
Now Thanks for sending your photo. We'll get in
touch with you soon after we've reviewed it. Right now, your account
has been disabled as a security precaution.
No timeline, no further information. Any ideas?
Facebook cleared me for access, without notification.

Is fb://authorize a valid URL Scheme for facebook?

I am trying to use native facebook app's authentication credentials in browser. Planning to use fb://authorize URL scheme, it seems it is not working.
Is there any way I can use native facebook application user credentials instead of asking the user to login again within the browser?
You can only do this with a native application on the device whose identity (bundle id on iOS, keyhash on Android) has been registered with Facebook. In all cases the identity of the native application is verified, the user must approve the permissions requested by the application, and the user has the ability to revoke these permissions in privacy settings.
It would violate users' privacy if it were possible for a web site to find out the identity of a user just because they had the Facebook app on the same device they were using to browse the internet.

Facebook login with multiple domains

I know that facebook allow me to specify multiple domains for my app.
But in the "Website with Facebook Login" i can only specify one url.
Is it possible for me, to authenticate users on domain.se, domain.dk and domain.net with the same App ? Or should i still create one app, for each domain ?
It is technically possible to use Facebook Connect on multiple domains, there are some limits (5 domains max).
So the key to doing this is adding all domains in the App Domain field under your app settings.
The PROBLEM, however, is that Facebook only lets you add domains that are derived from your Canvas URL or Site or Page tag URLs, so if you try to enter anything else you get an error that looks like this:
The SOLUTION is to create App on Facebook, Website, and Facebook Tab using the ADD PLATFORM button and then put in URLs that point to your other domains. Here is an example of what I mean:
If you use a unique domain for each field you can max out with 5 different domains. I have tested this technique with up to 3 domains, but i think it should work for all 5.
Note: Facebook admin features change from time to time, so all of this is subject to change
As long as you listed all the desired App Domains in application settings you should be able to authenticate users on any of them.
"Website with Facebook Login" is really only intended to be used as link to your site/application.
Update 2 (July 2016):
App domains must match the domain of the Secure Canvas URL, Mobile Site URL, Unity Binary URL, Site URL or Secure Page Tab URL.
Update (December 2013):
At the time of writing original answer it was possible to list any domains in application settings but from that time the UI of Application Settings (as well as way of handling Application Domains) changed at least couple of times, at some point you could only list domains that derive from one of application's canvas pages.
As of December 2013 it is possible (again) to list domains that do not derive from application canvas URL.
Assuming your domains are being served by the same web server and you have access to that web server, you can use the manual login procedure: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow to login from as many domains as you wish.
Assume your domains are site1.com,site2.com.... Instead of using the Facebook javascript API, you will simply place a plain old Log In with Facebook button on each site which will redirect the browser to the facebook login page as described in the above article. In the state variable you can specify a code which indicates which of your sites is requesting a login. In the redirect you will use a single service domain which you assign to your web server (e.g. fb.mywebserver.com) and which you specify as the verified redirect url in the facebook login settings page. All the sites will redirect to this same url, avoiding the problem of supporting multiple domains.
Once the user has logged in, the browser will redirect to fb.mywebserver.com and pass it the state, which tells you which site is requesting login and a code which you can use on the back end to retrieve the user's info using the Facebook graph apis. You store this info with a uid in your data store then using the info in state, you redirect to to the appropriate site including a parameter that indicates a Facebook login (e.g. site1.com?fbc={some uid}). The browser will obediently then call site1.com?fbc... Your web server will receive this request and detect the fbc parameter which tells it to associate the corresponding Facebook logged in user with this site. It can then retrieve the logged in users info using the uid and, for example, return a session cookie for this user along with the page. If you generate the page on the server you can, of course, also include a welcome "user" or alternatively, your client code can do an ajax call to retrieve that information.
From the user's standpoint they press the Login with Facebook button, are redirected to a Facebook login page where they login and then are redirected back to your site in a logged in state. Not quite as nice as having the login popup but likely acceptable.
A similar process can be used for google logins as well
Best thing I've found to do in the development/production scenario is add a "Test App", then add a platform for your development web site - as you have to provide where the "page tab url" lives if you use that as a platform.
Facebook requires your "page url" to be live / accessible if you need to apply for status or permission review.
This got me around the "login in development" / "login in production" scenario.