我正在使用 NSURLCredentialPersistencePermanent 创建一个 NSURLCredential 并使用它来验证 AFHTTPRequestOperation,如下所示:
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
NSURLCredential *credential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistencePermanent];
[operation setCredential:credential];
一旦通过身份验证,就不再需要在以后的操作中设置凭据。
但是,一旦我重新启动应用程序,而凭证仍然存在于 中[NSURLCredentialStorage sharedCredentialStorage]
,下一个 AFHTTPRequestOperation 将不再经过身份验证并返回拒绝访问响应。
为什么 AFNetworking 无法识别共享凭证存储中存在的凭证?