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
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
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
examples below will continue building off the one above
Here are a few of the basic methods that we could start off with
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
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
this is probably an obvious one.
Logs the user in using the specified platform.
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
}
});
Gets your profile information. Must be called after a Login
facebookSocial.me({
fields: "picture, id,name, email",
success: function( response ) { ... },
error: function( error ) { ... }
});
also obvious. Logs the user out.
possibly success/error callbacks
facebookSocial.logout();
A common way to get your friends list
success/error callbacks
facebookSocial.friends({
... //some settings,
success: function( response ){ ... },
error: function( error ) { ... }
});
a common way to "Post" something to whatever platform
the message you want to share.
facebookSocial.share(
... //settings,
message: { "a message to post" },
success: function( response ) { ... },
error: function( error ) { ... }
);