Yes/No + more question:
Is it possible to use the Facebook SSO system and simultaneously register a user for your own website/app?
As in requiring just one keypress on the part of the user.
Also, are there working examples of this on iPhone and Android?
From what i've read, there's a process for doing SSO and a separate process for doing registration.
The reasoning is that I'd like to keep my own record of user data in addition to what facebook gives me through the Insights system, BUT i would like to make this as painless as possible.
t;;dr has this been done before, what are some examples, and any useful and relevant documentation available?
A third-party authentication app (such as Google Authenticator or LastPass) can be used to generate login codes that help us confirm it's you when you log in from a new device for the first time. Install a third-party authentication app on your device.
Not really sure I understand you correctly, but assuming that you want to register a user in your own system without presenting a separate reg flow (?), you can do the following:
/me?fields=id,name,email
to get FB id, name and email). The Graph API Explorer is good for checking which fields you can get.POST
to your own system to create an account.To make this flow seamless to the user, you should probably show a loading/progress indicator during steps 1-4.
Facebook's SDK documentation should get you going with step (1).
Some sample (Objective-C) code for step (2) and partly (3):
- (void)facebookUserAuthorized
{
[FBRequestConnection startWithGraphPath:@"me"
parameters:[NSDictionary dictionaryWithObject:@"id,name,birthday,first_name,last_name,gender,email" forKey:@"fields"]
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSDictionary *userData = (NSDictionary*)result;
[self registerUserWithEmail:[userData objectForKey:@"email"]
facebookId:[userData objectForKey:@"id"]
gender:[userData objectForKey:@"gender"]];
}];
}
- (void)registerUserWithEmail:(NSString*)email facebookId:(NSString*)facebookId gender:(NSString*)gender
{
// Send a POST to your own server with the user details
}
And I'm sure you can apply the same principle on Android. Check out Facebook's Android docs to get started.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With