O'Reilly logo

RestKit for iOS by Taras Kalapun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Authorization

All authorizations are done through the AFNetworking library. The authorizations are mentioned in the following sections.

Basic

To authorize against the basic (or the simplest) authorization:

// client is instance of AFHTTPClient
[client setAuthorizationHeaderWithUsername:@"username" password:@"password"];

Token-based

The token-based authorization is mostly used with OAuth 1.0 / OAuth 2.0 authorization schemes. After authorizing with them, you will get a token string, which you need to supply to your AFHTTPClient:

// client is instance of AFHTTPClient
NSString *token = @"1q2w3e4r";
[client setAuthorizationHeaderWithToken:token];

Here, the setAuthorizationHeaderWithToken method actually sets an HTTP header Authorization with the Token token=1q2w3e4r ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required