ios – RestKit OAuth 2密码验证流程

我使用 RestKit与自己的OAuth2提供商.我尝试通过 Resource Owner Password Credentials认证.

任何人都可以提供一些示例代码和最佳实践,通过RestKit一般请求受保护的资源,并通过凭据进行身份验证以获取特定的访问令牌?

ResKit本身可能不是最好的选择吗?

解决方法

你应该看看这个链接: https://github.com/RestKit/RestKit/wiki/OAuth-Support-on-RestKit

你可以尝试这样的东西(我在我的应用程序代理中):

RKObjectManager *manager = [RKObjectManager objectManagerWithBaseURLString:@"http://www.yourdomain.com"];
[manager setSerializationMIMEType:RKMIMETypeJSON];

[[RKClient sharedClient] setAuthenticationType:RKRequestAuthenticationTypeOAuth2];
[[RKClient sharedClient] setUsername:@"username"];
[[RKClient sharedClient] setPassword:@"password"];

注意:我没有测试它,因为我使用AuthenticationTypeHTTPBasic

希望这可以帮助!

编辑:

我发现这个代码示例可以帮助您更多:https://github.com/rodchile/RestKit-OAuth2-Client-Example

以上是来客网为你收集整理的ios – RestKit OAuth 2密码验证流程全部内容,希望文章能够帮你解决ios – RestKit OAuth 2密码验证流程所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。