I am using RestKit with an own OAuth2 Provider. I try to authenticate via Resource Owner Password Credentials.
Could anyone provide some example code and best practices for requesting protected resources via RestKit in general and authenticating via credentials to get an access token in specific?
Probably ResKit itself is not the best choice?
You should check out this link: https://github.com/RestKit/RestKit/wiki/OAuth-Support-on-RestKit
You can try something like this (I do it in my app delegate):
RKObjectManager *manager = [RKObjectManager objectManagerWithBaseURLString:@"http://www.yourdomain.com"];
[manager setSerializationMIMEType:RKMIMETypeJSON];
[[RKClient sharedClient] setAuthenticationType:RKRequestAuthenticationTypeOAuth2];
[[RKClient sharedClient] setUsername:@"username"];
[[RKClient sharedClient] setPassword:@"password"];
Note: I haven't tested it because I use AuthenticationTypeHTTPBasic instead
Hope this helps!
Edit:
I found this code example that can help you more: https://github.com/rodchile/RestKit-OAuth2-Client-Example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With