OAuth on the iPhone
OAuth is a open protocol to allow secure API authorisation in a simple and standard method from desktop and web applications. Users won't need to provide their username and password to OAuth-enabled sites which makes for a safer internet.
If you're wanting to develop an iPhone application that makes use of an OAuth resource then you've got the following options:
Google Data APIs Objective-C Client Library
Google supply OAuth Controllers for iPhone and Mac Apps which once I got it working (thanks to some excellent assistance from Greg Robbins at Google.) seems to offer the best user experience. Signing in is handling within the application so the user is not thrown out into Mobile Safari. Of course there are debates as to which is better.
To use the the GDataOAuthTouchStaticLibrary in your project you'll need to:
- Select Project -> Add to Project and browse to gdata-objectivec-client-1.10.0/Source/ and select GDataOAuthTouchStaticLibrary.xcodeproj to add in
- Expand targets and perform a Get Info on your target
- Click on the + under Dependencies and select OAuthTouch
- Click Add Target
- With the targets expanded drag libOAuthTouch.a to "Link with binaries"
- Bring up the Project Info (all configurations)
- "-ObjC -lxml2" as a item under "Other Linker Flags"
- Add in the security framework
- Under classes create a new group called OAuth. Add in
- GDataOAuthAuthentication.h
- GDataOAuthViewControllerTouch.h
(A local archive of a working project is saved locally)
mpoauthconnection
While I've not yet got a sample application working correctly with this the following steps are useful to get the library included with your project:
- Bring up the Project Info (all configurations)
- Add "/usr/include/libxml2" as a item under "Header Search Paths"
- "-lxml2" as a item under "Other Linker Flags"
- Add in the security framework
- Under "Other Sources" you should see a file ending in _Prefix.pch where you'll need to add in #import "MPDebug.h"
- Copy oauthAutoConfig.plist over to your resources and ensure that the service you're wanting to use is setup in there. If you don't you'll run into http://code.google.com/p/mpoauthconnection/issues/detail?id=31#c0
- And lastly follow the steps on Launching Your Own Application via a Custom URL Scheme
Snapup seems to be a good example of using this library as it covers custom URL schemes etc. (a local copy has been archived here)
OAuthConsumer
I did try and use this but think I had terrible issues in getting it to compile. However a sample application, iPhone Updater for Fire Eagle, at http://github.com/fireeagle/fire-eagle-iphone-updater is available which might help. (A local copy has been archived here)
An "iPhone Ready" version is available from http://github.com/jdg/oauthconsumer