Could the iOS social api be used to authenticate people (so users can log into your app) using facebook or twitter?

Clarification . If you want to ONLY use the iOS provided social API (account infrastructure), can you allow users to log into your app with their facebook or twitter accounts?
If so, what do you use along with the user id (or name, twittername, facebook name) to verify (server side) who they are.

More expressive explanation I'm having a hard time understanding the 3rd party registration and login sequence / logic in a native iOS (or Android) app So iOS has a central store that stores twitter (or facebook) user credentials and the app can call api to get users twitter id, how good is that, but if I want to talk to the backend server and prove that the user is who claims the user id just isn't enough,
am I missing something?

My question is , how do you authenticate a user to your server if they do not verify your credentials?

+3


source to share


1 answer


You can authenticate with ACAccountStore. Thanks to http://blogs.captechconsulting.com/blog/eric-stroh/ios-6-tutorial-integrating-facebook-your-applications for most of the code below.

self.accountStore = [[ACAccountStore alloc]init];
ACAccountType *FBaccountType= [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSString *key = @"987654"; //put your own key from FB here
NSDictionary *dictFB = //use the ACAccountStore ACFacebookPermissionsKey to help create your dictionary of permsission you'd like to request, such as the users email, writing on the wall, etc.
[self.accountStore requestAccessToAccountsWithType:FBaccountType options:dictFB completion: ^(BOOL granted, NSError *e) {
    if (granted) {
        NSArray *accounts = [self.accountStore accountsWithAccountType:FBaccountType];
        //it will always be the last object with SSO
        self.facebookAccount = [accounts lastObject];
    } else {
        //Fail gracefully...
        NSLog(@"error getting permission %@",e);
    } 
}];

      



At this point, you have access to the oauth token in the accountStore, which you can send to your server for whatever server side interaction you want with facebook.

0


source







All Articles