用UIWebView访问BASIC认证的页面
2013-01-10 00:30
155 查看
比如类似下面的 URL,
需要用户的认证,如果用 UIWebView 访问这样的页面,可以使用下面的委托方法。
具体参数形式如下。
利用第3个参数—认证的Challenge对象(NSURLAuthenticationChallenge)的 sender 方法,红色纸认证的信息。如果认证失败,可以从NSURLAuthenticationChallenge 的 previousFailureCount 中取得失败的次数。
1 | http://user:password@www.example.com/ |
1 | - (void)webView:(id)fp8 resource:(id)fp12 didReceiveAuthenticationChallenge:(id)fp16 fromDataSource:(id)fp20; |
12 | - (void)webView:(UIWebView *)webView resource:(NSObject *)resource didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource; |
12 | - (void)webView:(id)webView resource:(id)resource didReceiveAuthenticationChallenge:(id)challenge fromDataSource:(id)dataSource { NSURLCredential *credential = [NSURLCredential credentialWithUser:@"user" password:@"password" persistence:NSURLCredentialPersistenceForSession]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; } |
相关文章推荐
- iPhone开发技巧之私有API(7)--- 用UIWebView访问BASIC认证的页面
- iPhone开发技巧之私有API--- 用UIWebView访问BASIC认证的页面
- nginx让用户通过用户名密码认证访问web页面
- nginx让用户通过用户名密码认证访问web页面
- nginx让用户通过用户名密码认证访问web页面
- nginx让用户通过用户名密码认证访问web页面
- nginx让用户通过用户名密码认证访问web页面
- 通过Basic认证,访问带有账户登录验证的网站资源
- 基于basic认证机制配置httpd服务器拥有用户访问控制功能
- 访问需要HTTP Basic Authentication认证的资源的各种语言的实现
- nginx实现用户认证访问页面
- nginx让用户通过用户名密码认证访问web页面
- nginx让用户通过用户名密码认证访问web页面
- 访问需要HTTP Basic Authentication认证的资源的各种语言的实现
- 访问需要HTTP Basic Authentication认证的资源的各种语言的实现
- 访问需要HTTP Basic Authentication认证的资源的各种语言的实现
- nginx让用户通过用户名密码认证访问web页面
- nginx让用户通过用户名密码认证访问web页面
- ubuntu php访问带apache2基本认证的页面
- nginx让用户通过用户名密码认证访问web页面