我是否可以在没有用户交互的情况下对 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.
有一种认证方式:
- (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/