ios - iOS 社交 api 是否可用于使用 facebook 或 twitter 对人员进行身份验证(让人们登录到您的应用程序)?

标签 ios facebook authentication twitter

澄清如果您只想使用 iOS 提供的社交 API(帐户框架),您可以让用户使用他们的 facebook 或 twitter 帐户登录您的应用吗?
如果是,那么您将什么与用户 ID(或名称、推特名称、Facebook 名称)一起使用以确保(在服务器端)他们是谁。

更具表现力的解释 我很难理解 native iOS(或 Android)应用程序中第 3 方注册和登录集成背后的工作流程/逻辑, 所以在 iOS 中有一个中央存储,可以保存用户的推特(或 Facebook)凭据,应用程序可以调用 API 来获取用户的推特 ID,到目前为止还不错,但是如果我想与后端服务器交谈并证明用户是他们自称的人只是拥有用户 ID 是不够的,
我错过了什么吗?

我的问题是如果用户不向您提供凭据,您如何通过后端服务器对用户进行身份验证?

最佳答案

您可以使用 ACAccountStore 进行身份验证。感谢http://blogs.captechconsulting.com/blog/eric-stroh/ios-6-tutorial-integrating-facebook-your-applications对于下面的大部分代码。

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);
    } 
}];

此时,您可以访问 accountStore 中的一个 oauth token ,您可以将该 token 发送到您的服务器,以便与 facebook 进行任何服务器端交互。

关于ios - iOS 社交 api 是否可用于使用 facebook 或 twitter 对人员进行身份验证(让人们登录到您的应用程序)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14910864/

相关文章:

android - Facebook 在 Android 上的 React

iphone - OAuth 问题,带参数的 POST

ios - 如何检测 UIWebView 何时更改页面?

ios - Swift 中多个 UIViewContoller 中的 NSNotification 处理

ios - 获取由 UIView 的 animateWithDuration 创建的动画的引用或通过任何其他方式识别它

php - 用 PHP 发送电子邮件到 Facebook 组邮件地址

ios - 开发过程中应该如何使用identifierForVendor?

facebook - 使用 Facebook 登录 - 不安全的登录被阻止

javascript - 在没有第三方应用程序的情况下实现两要素身份验证

php - 如何更改 token guard 中的 api_token 列