tags:

views:

637

answers:

2

Launching a URL in Safari is easy enough in an iPhone application - UIApplication's openURL method.

However, I'm doing some OAuth stuff, and want to follow the pattern that pownce used to handle OAuth. But since OAuth wants me to explicitly set the Authorization header, I don't know how to proceed. I can set headers via NSMutableURLRequest... but how does that translate into creating an NSURL that my app can pass to the UIApplication method?

A: 

From what I've seen, the usual way to implement OAuth support in an iPhone application is to present a modal sheet with a webview in it. This allows you to use an NSURLRequest with custom headers.

Brent Royal-Gordon
This is true but it goes against the spirit of OAuth to present the page inside of your own application.
bpapa
+2  A: 

During server to server interactions the recommended method of passing OAuth parameters from the Consumer to the Service Provider is using the HTTP Authorization header. But when the user is redirected by the Consumer to the Service Provider OAuth actually specifies that an HTTP GET request should be used (see section 6.2.1, I can't link b/c I'm a new user and can only post one hyperlink -- very annoying StackOverflow). So there's no need to pass an NSURLRequest off to mobile safari, simply open the URL as you described.

If you're interested in seeing a code example of the full OAuth flow on the iPhone feel free to check out the sample FireEagle app I wrote. It was implemented in much the same way the Pownce app was.

mmalone
Thanks a lot for chiming in, Mike!
bpapa