ios - 使用内部应用程序凭据而不是用户凭据对 iOS 应用程序进行身份验证

标签 ios facebook authentication

我是否可以在没有用户交互的情况下对 iOS 应用程序进行身份验证,使其达到可以向 Facebook 请求页面数据的级别?

例如,在音乐家的应用程序中,我希望能够向 facebook 请求音乐家的艺术家页面,包括墙贴。然后我可以获得他们页面的原始数据并根据需要设置样式。这不需要用户登录, session 身份验证将由应用程序本身使用嵌入式凭据异步完成。

我想使用 SDK,但我认为这需要手动 OAuth 访问 token 请求和发布。

感谢您的帮助!


更新:

澄清一下,我对以下可能性感到好奇:

1) 应用加载 OAuth 访问 token 并使用嵌入到应用中的凭据发出请求 2) 然后应用程序可以向 facebook 请求来自预定页面提要的提要数据 3) 这些都不需要任何用户交互或将应用程序跳转到移动 safari 等。

最佳答案

我不太明白你想要什么,但是可以在没有用户交互的情况下进行身份验证:

If the request requires authentication in order to make the connection, valid credentials must already be available in the NSURLCredentialStorage, or must be provided as part of the requested URL. If the credentials are not available or fail to authenticate, the URL loading system responds by sending the NSURLProtocol subclass handling the connection a continueWithoutCredentialForAuthenticationChallenge: message.

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/AuthenticationChallenges.html#//apple_ref/doc/uid/TP40009507-SW1

有一种认证方式:

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
   return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
     if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
         [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
     [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}

关于ios - 使用内部应用程序凭据而不是用户凭据对 iOS 应用程序进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11786296/

相关文章:

ios - 有什么方法可以防止新用户下载应用程序,但仍然为现有用户提供错误修复?

ios - 我是否必须重新启动设备才能重新安装篮板调整?

java - 使用 Spring、Swing 和 SQLite 在 Java 中进行用户授权

java - 使用 shiro 1.2.1 对数据库进行身份验证

iphone - 如何以编程方式使声音变大?

c++ - 如何避免 iOS 二进制文件中的符号和源路径?

c# - OAuth 异常问题

facebook - 在最近的 Facebook 维护后尝试向群组发帖时出现 oAuth 异常 #200

Android:Facebook 登录按钮

javascript - 桌面版 Internet Explorer 11 中的 Instagram 登录字段未激活