0

Really struggling with facebook at the moment

I am trying to auth a user using openfb and facebook on an ios app being built with cordova (ionic). I have tried all the solutions I could find online.

My configuration is standard, and an almost copy and past of the openfb example. Without a callback url and with the following callback urls () I am getting the image you see on this facebook Security Warning while user has enabled secure login - iPhone

When I specify the callback url of http://localhost/oauthcallback.html. I get a Facebook mobile looking page with title, Error and message "Given URL is not permitted by the application configuration.: One of more of the given URLs is not allowed by the App's settings. It must watch the Website URL or canvas URL, or the domain must be a subdomain of one of the App's domains.

Note: works perfectly on web!

Can someone eplse point me in the direction to set this up once and for all on both Facebook and in openfb?

Please help!!!! :)

Community
  • 1
  • 1
Stuart McCamley
  • 111
  • 1
  • 7
  • Have you thought about using something like this?: https://github.com/nraboy/ng-cordova-oauth – Nic Raboy Feb 06 '15 at 16:25
  • I have not and nice idea, but still i feel like this is an xcode/facebook problem, I dont have time to implement a new login. Really need this one to work :( – Stuart McCamley Feb 06 '15 at 16:53

1 Answers1

0

user1132726,

I struggled with that for days as well, looked over lots of forums, tried everything. Then I turned away to Javascript only.

We must have the right Javascript libraries in the right order. Some you can download, some you won't find easily.

<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="https://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="js/cdv-plugin-fb-connect.js"></script>
<script src="js/openfb.js"></script>

Then you use regular Javascript logic to select your elements and use openfb API like:

openFB.login(
    function(response) {
        if (response.status === 'connected') {
            alert('Facebook login succeeded, got access token: ' + response.authResponse.token);
            // DO YOUR LOGIC HERE, I use perception: $.FacebookPerception.submit(response.authResponse.token);
        } else {
            alert('Facebook login failed: ' + response.error);
        }
    }, { scope:'email,public_profile,user_likes,user_friends'});

You must as well register your application at Facebook using Developers Console: http://developers.facebook.com . I used the website configuration with my main url: http://www.texugo.com.br/

I don't think you need other configurations. I tested only on Android. I don't know if you need to configure your App for Android at Facebook Console. I think it is not really used but haven't tested yet.

IMPORTANT: you need version 0.4 for openfb.js

Then you run Apache Cordova and deploy it to your mobile.

Further steps:

  1. When you call Facebook it opens on a popop that Cordova applies InAppBrowser, but I want to hide that ugly header that looks weird.

  2. Integrate with Google+, LinkedIn and Twitter

  3. Create OpenSocialAuth plugin

OBSERVATION: this is only working with Android, it does not work in web browsers. Gotta check it as well.

Hope it helps. Anything question me. I'm pretty sure I missed something.

See you.