FatFractal customer forums



Author Topic: Facebook login and Fatfractal integration  (Read 2024 times)

armin65

  • Newbie
  • *
  • Posts: 9
    • View Profile
Facebook login and Fatfractal integration
« on: December 07, 2014, 04:02:10 PM »
Hello developers and users,

I am trying to use Facebook SDKs to login(already implemented) to my app and at the same time authenticate the user in fat fractal (in background) is this possible? How should I go about this? I

Any helps or pointers would be appreciated 

cheers,
armin

dave

  • Administrator
  • *****
  • Posts: 52
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #1 on: December 09, 2014, 12:54:58 PM »
Hi armin,

Please take a look at this page giving some basic usage of ScriptAuth, which allows Facebook login (among other things):

http://fatfractal.com/v2/document/scriptable-authentication

That should get you going. If you hit any roadblocks, please let us know and we'll help you out.

Dave

armin65

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #2 on: December 10, 2014, 03:56:54 PM »
Hello Dave,

thanks for helping out. I followed your suggestions and I hit a problem on deploying locally. So first question is; "Is testing Facebook-auth even possible locally?" if yes then read on ;

I am getting the following run time error from the engine when I fire up the Facebook-auth.

"
!!!APPLICATION[*********] IS READY FOR REQUESTS!!!
ERROR - STACK_TRACE - 2014.12.10 50 at 09:54:03.686 PM CET - com.fatfractal.core.nio.protocol.http.parser.HTTPException: invalid method
   at com.fatfractal.core.nio.protocol.http.parser.lolevel.ParserSettings.call_on_error(ParserSettings.java:41)
   at com.fatfractal.core.nio.protocol.http.parser.lolevel.HTTPParser.error(HTTPParser.java:1155)
   at com.fatfractal.core.nio.protocol.http.parser.lolevel.HTTPParser.execute(HTTPParser.java:312)
   at com.fatfractal.core.nio.protocol.http.HttpProtocolDecoder.decode(HttpProtocolDecoder.java:141)
   at com.fatfractal.core.nio.synchronous.ReactorHandler.run(ReactorHandler.java:104)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)

ERROR - com.fatfractal.core.nio.protocol.http.HttpProtocolDecoder - 2014.12.10 50 at 09:54:03.706 PM CET - position[180]"

this happens with the following call:

"fatFractal.authUriForScriptAuthService(scriptAuthService, error: &authError)" (I changed the syntax to swift)

and then the client side is stuck until it throws a timed out request.

any pointers would be appreciated

cheers,
armin

« Last Edit: December 10, 2014, 04:07:55 PM by armin65 »

dave

  • Administrator
  • *****
  • Posts: 52
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #3 on: December 10, 2014, 05:13:52 PM »
Hi Armin,

Yes you can definitely test locally for Facebook auth, the only tricky part is setting an OAuth callback URL that Facebook will accept. I think I set the canvas app URL to something on localhost to facilitate that.

The problem you're having is related to HTTPS. I'm guessing you don't explicitly set the SSL URL of your app. If you're using our cloud footprint then this isn't an issue because it is simple to derive from the base (non-HTTPS) URL, but locally we use non-standard ports. Anyway, you need to do something like this:

Code: [Select]
FatFractal *ff = [[FatFractal alloc] initWithBaseUrl:@"http://localhost:8080/your_app_context" sslUrl:@"https://localhost:8443/your_app_context"];

Dave

armin65

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #4 on: December 11, 2014, 12:44:08 PM »
Hello Dave,

It seems I still have problems getting this to work with the server. Somehow the server does not see the changes that I have made to the Auth.js file (to account for the facebookID and secret) It only sees the default one, that is when I write out the authUrl from the client side I get this:(Facebook_app_id instead of the actual id)

https://www.facebook.com/dialog/oauth?client_id=facebook_app_id&redirect_uri=.......

Any ideas what might be going wrong this time?

dave

  • Administrator
  • *****
  • Posts: 52
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #5 on: December 11, 2014, 01:35:52 PM »
Did you redeploy your app after making the changes?

armin65

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #6 on: December 11, 2014, 02:47:41 PM »
Hi dave yes I did

dave

  • Administrator
  • *****
  • Posts: 52
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #7 on: December 11, 2014, 04:30:34 PM »
Hmm, then I don't know what else to suggest, that doesn't make sense. All I can suggest it to try deploying again, and watch the engine output for any errors that might be preventing the redeploy from succeeding. If you're using a cloud backend, you can also give me your app domain and context and I can take a look at it.

armin65

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #8 on: December 14, 2014, 06:40:22 PM »
Hi Dave,
So I have solved the problem with scaffolding the app again and reinstalling the local engine, now the problem is supposedly  I have to define a callbackUri on the client side, But Facebook throws the following error for the local one I have chosen :

"Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains."

callbackuri = "https://localhost:8080/darkLady/authorize"

dave

  • Administrator
  • *****
  • Posts: 52
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #9 on: December 16, 2014, 02:25:19 PM »
Yeah Facebook it picky that way. I'd recommend going through and seeing what you app tries to use as its callback URI (on local machines it can vary a little, but should be something like http://localhost:8080/darkLady/ff/auth or http://My-Computer.local:8080/darkLady/ff/auth), then using the first part as either your app's Canvas URL or Site URL, e.g.

http://localhost:8080/darkLady

You may then need to add the domain to your app's list of App Domains (toward the top of you Facebook app settings.) Once you've done all that, things should start working. If not, post the full callback URI your app tries to use and we can go from there.

Dave

armin65

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #10 on: December 17, 2014, 05:33:40 AM »
thanks for sticking with me on this,

so I tried what you suggested and I still get the same error. The complete URL that is being sent to Facebook is :

https://localhost:8443/darkLady/ff/auth?action=getAuthUri&scriptAuthService=FACEBOOK&callbackUri=darkladyfb

so I used https://localhost:8443/darkLady

then also for test purposes I also tried

https://localhost:8080/darkLady

And the thing is for an iOS app you cannot even set the canvas URL directly in the platform, you can only set the bundle Id, so I added a web platform to Facebook and then added the urls there, I guess that's what you meant with adding the urls.

dave

  • Administrator
  • *****
  • Posts: 52
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #11 on: December 17, 2014, 06:04:38 PM »
Yep, that's right, you need to add platforms so that you can put in the URL you need to use. It's a pain but that's how it is with Facebook.

So, back to your problem. It looks like you're doing the right thing, so I'm starting to get a bit stumped. Did you add 'localhost' to the App Domains? Also if you could send/attach a screenshot of the following, it would be very helpful:

1. The exact error message you get from Facebook
2. Your Facebook app settings

Finally, just for fun, you might try using the address

http://localhost:8080/darkLady

Note that this is a plain http address (no s.) That is the protocol expected on port 8080.

armin65

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #12 on: December 18, 2014, 06:52:02 AM »
Hi dave

yes I have added the localhost to app domains. Also i tried out every possible combination of http://localhost:8080/darkLady with s and without with 8080 and with 8443. And I still get the same error.

here are the screenshots

EDIT: btw I just tested the application with fat fractal servers and I get the same error, so I don't think the problem is only with local hosts, I also get the same error with or without URL Scheme suffix (here darkladyfb). I also tried filling Valid OAuth redirect URIs in dashboard and surprise surprise ; same error.
« Last Edit: December 18, 2014, 11:57:24 AM by armin65 »

dave

  • Administrator
  • *****
  • Posts: 52
    • View Profile
Re: Facebook login and Fatfractal integration
« Reply #13 on: December 18, 2014, 12:42:06 PM »
OK, one more question: Can you post the authorization URI you get? This is the result of a call to authUriForScriptAuthService:error:, i.e. uri below:

Code: [Select]
FatFractal *ff;
// ...
NSError *err;
NSString *uri = [ff authUriForScriptAuthService:FF_SCRIPT_AUTH_SERVICE_FACEBOOK error:&err];

Thanks ... we'll get you up and running!

Dave


 

Copyright © FatFractal customer forums