Forum QuickConnect Facebook Auth

Discussion and help relating to PlayerIO's QuickConnect feature, including Facebook Connect and Kongregate Connect.

Facebook Auth

Postby INS » June 22nd, 2010, 4:55 pm

Hello! I'm sorry if my question is kind of noobish, it's my very first experience integrating applications with facebook.

Could someone give me an example or 1-2-3 steps guide on a proper way to auth via facebook or kongregate?

Actually, I've already managed to authorize, but I feel it's not the best way to do this. My current auth procedure looks like this:

1. User clicks "Authorize to facebook" button.
2. Using Facebook's AS3 API i'm bringing down a new browser window with a facebook page requesting to log in.
3. User authorizes and returns to the app.
4. App validates if auth is ok and if it is...
5. Connecting with PlayerIO's quickConnect, which returns my FB.uid as connectionUserId.

This works well, but I feel there must be an easier way.. Too much actions for user, click, auth, click again.. I have a slight feeling, I'm doing something wrong. Can someone give me a kick to a proper direction?

What's the best way to create application's user management architecture? Playing as guest and authorizing only within a score submit? Registering and logging in as PlayerIO's simpleUser and adding linkages to Facebook and Kongregate profiles? Different profiles?
INS
 
Posts: 12
Joined: June 19th, 2010, 8:22 am

Re: Facebook Auth

Postby Benjaminsen » June 22nd, 2010, 5:16 pm

Hey Ins

The complex process you describe is exactly what we tried to make better with QuickConnect. We basically build a solution where we automatically detect when the user authenticated.

Scroll down to the bottom of the above linked page for an example of how to use the facebookConnectPopup to make the experience much more smooth for your users.

You can see the system in action at http://www.m-ball.com/.

Lastly, I suggest you don't ask users for extended permissions before the user wishes to do something that requires it.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Facebook Auth

Postby INS » June 22nd, 2010, 5:51 pm

Thanks, Benjaminsen. Actually, M&M's game was the thing inspired me to make facebook connection to my game. Facebook connection in this gameis realy simple. So, what's the architecture? In-game account is kinda "simplePlayer" connected with facebook uid? An automatic in-game registration happens if "Connect to facebook" chosen?

What do I put in "Go To App Url" in quickconnect settings at admin panel? A page that just closes popup? How does that popup appear? ExternalInterface call to create popup, then navigate quickConnect to new window? Maybe, closing popup happens via ExternalInterface call again? Any specific facebook setup except for "Connection Url"?

Thanks again, things getting clear.
INS
 
Posts: 12
Joined: June 19th, 2010, 8:22 am

Re: Facebook Auth

Postby Benjaminsen » June 22nd, 2010, 5:58 pm

Users authenticated via facebookConnectPopup are simpleUsers like users you register yourself and It's all automatic if you use the method. You might however want to show a migration the first time they connect, such that you can collect more data. For this we simply do a BigDB lookup to see if the data is already there. If not, we show the migration registration.

To spawn the popup simply make an external interface call to create the popup, then use the popup name as the target for the facebookConnectPopup method. The window will always try to close itself on successful auth.

The "Go To App Url" is the url you should be redirected to when you click on the "go to application" link on the facebook application page for the game.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Facebook Auth

Postby INS » June 22nd, 2010, 9:19 pm

Well, now it's all clear, i've implemented facebook auth. But i also have to report some sort of bugs (not bugs actually, but things you guys got to fix):

1. When editing QuickConnect settings for facebook in admin panel, there is a line saying:

You also have to set the Connect Url of the Facebook App in Facebook to:
http://api.playerio.com/services/quickc ... RIO_KEY__/


But if set like this, it brings a Facebook error on a popup:

Invalid Argument
The Facebook Connect cross-domain receiver URL (http://api.playerio.com/services/quickc ... _API_KEY__) must have the application's Connect URL (http://api.playerio.com/services/quickc ... RIO_KEY__/) as a prefix. You can configure the Connect URL in the Application Settings Editor.


If already logged in to facebook this causes infinite redirect.

Fixing this is easy, just as facebook page recommends, set Connection URL to:

http://api.playerio.com/services/quickc ... ERIO_KEY__?
(with a "?" sign at the end)

Please, add "facebookconnectreceive" url piece to edit quickConnect settings screen.

2. Documentation on quickConnect.facebookConnectPopup says that onSuccess callback invokes with these 4 arguments:

api_key:String, uid:String, session_key:String, secret:String

But in fact, there are 5 arguments passed:

client:Client, api_key:String, uid:String, session_key:String, secret:String

Please, update documentation :)

----

That's it. Thanks for your help. Creating player accounts and connecting to facebook realy takes 2 lines of code, if you can understand the principals.
INS
 
Posts: 12
Joined: June 19th, 2010, 8:22 am

Re: Facebook Auth

Postby INS » June 22nd, 2010, 9:29 pm

Also, if user does not authorize (presses "Cancel" i.e.) quickConnect still recalls "onSuccess" callback (with a null as Client.connectUserId) instead of onError.
If user just closes the page without authorizing - how do i know that happen? I'm waiting for onError callback, but this seems like does not happen.

Or maybe it's me who does something wrong?
INS
 
Posts: 12
Joined: June 19th, 2010, 8:22 am

Incorrect Connect URL in Docs

Postby actionsprite » June 28th, 2010, 9:21 am

Thanks INS,
I was having the same problem regarding the prefix error thrown by Facebook. Could you please fix up the hint in the QuickConnect setup wizard as well as the docs, the Connect URL should be:

Code: Select all
http://api.playerio.com/services/quickconnect/facebookconnectreceive/<gameid>?

and NOT
Code: Select all
http://api.playerio.com/services/quickconnect/<gameid>/


as is currently advised.

Cheers!
JMC
P.S. really impressed with player IO so far, it's providing so much functionality that invaluable, thanks so much for all the great work!
actionsprite
 
Posts: 21
Joined: June 26th, 2010, 1:01 am

Re: Facebook Auth

Postby Benjaminsen » June 30th, 2010, 6:06 pm

Yesterday I build a small example of using facebookConnectPopup and I am not seeing the issues you describe.

Example here code, and setup explanation here: post1501#p1501

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Facebook Auth

Postby actionsprite » July 1st, 2010, 5:03 am

Thumbs up for the Flashdevelop format.

When logged out of facebook, if I substitute in my game ID I get the following error on the facebook page:

Code: Select all
Invalid Argument
The Facebook Connect cross-domain receiver URL (http://api.playerio.com/services/quickconnect/facebookconnectreceive/<game id>?success=0&communicationId=1277956173250&api_key=<api key>) must have the application's Connect URL (http://api.playerio.com/services/quickconnect/<game id>?) as a prefix. You can configure the Connect URL in the Application Settings Editor.


I've commented out the game and api ids but as with my post above that's when using the suggested Connect URL - if I swap it to the url that contains "facebookconnectreceive" it works fine.
actionsprite
 
Posts: 21
Joined: June 26th, 2010, 1:01 am

Re: Facebook Auth

Postby Benjaminsen » July 1st, 2010, 11:44 am

Did this example work for you?
http://chrisbenjaminsen.com/stuff/facebookconnect.swf

Also did you create the url yourself or copy it from the quickconnect administration page?

Lastly whats in your Base Domain on the Connect tab on your facebook application?

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Facebook Auth

Postby actionsprite » July 1st, 2010, 12:14 pm

Hi Chris,
Yep, that demo does work for me. With mine I copy/pasted the URL from the admin page into facebook. The Base Domain is blank - should I have put something in there?

JMC
actionsprite
 
Posts: 21
Joined: June 26th, 2010, 1:01 am

Re: Facebook Auth

Postby Benjaminsen » July 1st, 2010, 2:19 pm

actionsprite wrote:Hi Chris,
Yep, that demo does work for me. With mine I copy/pasted the URL from the admin page into facebook. The Base Domain is blank - should I have put something in there?

JMC


Try adding in api.playerio.com as the base domain
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Facebook Auth

Postby actionsprite » July 1st, 2010, 2:38 pm

Hi Chris that works!

So now the Connect URL:
Code: Select all
http://api.playerio.com/services/quickconnect/<gameid>?

and the Base Domain:
Code: Select all
api.playerio.com


For interests sake, is there any downside to using:
Code: Select all
http://api.playerio.com/services/quickconnect/facebookconnectreceive/<gameid>?

and not having a Base Domain?

JMC
actionsprite
 
Posts: 21
Joined: June 26th, 2010, 1:01 am

Re: Facebook Auth

Postby Benjaminsen » July 1st, 2010, 2:44 pm

actionsprite wrote:Hi Chris that works!

So now the Connect URL:
Code: Select all
http://api.playerio.com/services/quickconnect/<gameid>?

and the Base Domain:
Code: Select all
api.playerio.com


For interests sake, is there any downside to using:
Code: Select all
http://api.playerio.com/services/quickconnect/facebookconnectreceive/<gameid>?

and not having a Base Domain?

JMC


You should rally use a trailing slash instead of the question mark you use. IE
Code: Select all
http://api.playerio.com/services/quickconnect/<gameid>/


The whole reason for having the game ID etc in the connection url is that it makes the "Got to Application" on the application overview page work. (http://o.ogmy.com/115004589119d1dd3d6a5b835ab57c3d.png)

I would not recommend using the url containing facebookconnectreceive for the simple reason that I cannot guarantee you that it will work in the future.

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Facebook Auth

Postby actionsprite » July 2nd, 2010, 6:45 am

Makes sense - thanks Chris
actionsprite
 
Posts: 21
Joined: June 26th, 2010, 1:01 am


Return to QuickConnect



cron