[aerogear-dev] AG Social

Lucas Holmquist lholmqui at redhat.com
Mon Apr 1 11:43:20 EDT 2013


This only shows a facebook example, but i just wanted to get a highlevel discussion going. I have a JS implementation, partial, since i am using it in another project. But it is tailored to my needs.

I'm sure i forgot a few things


AeroGear Social

Since this can be more that just a "login", it probably needs it's own category instead of being added to Auth.

Basically, i see AG Social as a common way to access social network api's such as facebook[1], google plus[2], twitter[3], and others.

It would be a wrapper around the current platform SDK's

There are a couple a common themes for most if not all the social platforms

you need to create an "app" on the respective platform that can act on your behalf
you need to provide "scopes", which are what information the app can access.
For example, using the Facebook SDK, you cannot access the users email by default. you need to provide this scope and the user will have to authorize the usage when they log in.

a quick javascript example of how it could look during creation

var AGSocial = AeroGear.Social();

AGSocial.add({
    name: "FB",
    type: "facebook",
    settings: {
        clientId: "1234567890", //the app id provided by the platform
        scopes: "email", //the "extended permissions" we want the user to authorize
        channelFile: "//www.site.com/channel.html"  //specific to facebook,  for crossdomain
        ....  //Other platform specific settings or just other settings
    }
});

var facebookSocial = AGSocial.socials.FB;
while "socials" might be a good name for the "modules", i'm still leaning to "stalkers", but probably not appropriate

Proposed API's - to Begin with.  All names a debateable

examples below will continue building off the one above

Here are a few of the basic methods that we could start off with

LoadSdk

This loads the SDK of the specified platform.

The SDK's documentation recommends loading the scripts asynchronously. This gives a common way to load and then, if needed, wait for all the "socials" sdk's to load

Returns a promise object
takes loaded callback, probably name it success. also perhaps an error callback

facebookSocial.loadSDK({
    success: function() {
         //loaded
    }
});
for JS, i wanted to load the sdk during the Login() method, but popup blockers interfere with this idea

Login

this is probably an obvious one.

Logs the user in using the specified platform.

takes success/error callbacks
callbacks return the response from the platform.

facebookSocial.login({
    success: function( response ) {
        //returns the auth response from the specified platform, when success is determined
    },
    error: function( error ) {
         //returns the auth response from the specified platform, when an error is determined
    }
});
Me

Gets your profile information. Must be called after a Login


takes a list of "fields" to bring back, or return all default( passed on platform ) fields
success/error callbacks
success/error callbacks returns response from the server
    facebookSocial.me({
        fields: "picture, id,name, email",
        success: function( response ) { ... },
        error: function( error ) { ... }
    });
Logout

also obvious. Logs the user out.

possibly success/error callbacks

facebookSocial.logout();
Other Possible API's to begin with

Friends

A common way to get your friends list

have various settings based on platform
success/error callbacks

facebookSocial.friends({
    ... //some settings,
    success: function( response ){ ... },
    error: function( error ) { ... }
});
Share

a common way to "Post" something to whatever platform

settings based on platform
success/errorbacks
the message you want to share.

facebookSocial.share(
    ... //settings,
    message: { "a message to post" },
    success: function( response ) { ... },
    error: function( error ) { ... }
);


[1] [2] [3]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20130401/da67a24e/attachment-0001.html 


More information about the aerogear-dev mailing list