-
Notifications
You must be signed in to change notification settings - Fork 0
HTTP Authentication Support on RestKit
HTTP Authentication is the simplest method to implement, especially if you are creating your own REST service. RestKit supports HTTP AUTH digest and other flavors supported by NSURLConnection. For other authentication standards, see OAuth Support on RestKit.
See Tutorial : Introduction to RestKit for a general overview. Below are details for creating an authenticated client.
// Be default, this will create a client with RKRequestAuthenticationTypeHTTPBasic
[RKClient clientWithBaseURL:@"http://example.com/api/" username:@"bob" password:@"s3cr3t"];
While outside the scope of RestKit, the following information will help you if you are also implementing the server side of your REST application.
PHP HTTP Auth Documenation has a straightforward example. Copy the Basic or Digest sample code into http://example.com/api/index.php and you should be up and running immediately. If your API has multiple php files, create an include file with that code, and include it at the top of each file.
- Make sure you have the Auth Digest module installed in your webserver. This is often not installed on hosted servers. For Apache, you can test this with 'httpd -M' on the command line, and look for 'auth_digest_module'