<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>matrixPointer➔blog &#187; MPOAuth</title>
	<atom:link href="http://matrixPointer.com/karl/posts/tag/mpoauth/feed" rel="self" type="application/rss+xml" />
	<link>http://matrixPointer.com/karl</link>
	<description></description>
	<lastBuildDate>Tue, 25 Aug 2009 03:35:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MPOAuth on the iPhone, MPOAuthMobile</title>
		<link>http://matrixPointer.com/karl/posts/mpoauth-on-the-iphone-mpoauthmobile</link>
		<comments>http://matrixPointer.com/karl/posts/mpoauth-on-the-iphone-mpoauthmobile#comments</comments>
		<pubDate>Sun, 15 Feb 2009 01:11:49 +0000</pubDate>
		<dc:creator>Karl Adam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[MPOAuth]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[Social]]></category>

		<guid isPermaLink="false">http://matrixPointer.com/karl/?p=32</guid>
		<description><![CDATA[MPOAuthMobile, a small sample application that will demonstrate that basics of setting up your iPhone app to use MPOAuth. In this example the Twitter OAuth beta will be used, but any valid OAuth Producer can also be used]]></description>
			<content:encoded><![CDATA[<p>Some people have expressed difficultly in using MPOAuth on the iPhone, so I commited a test iPhone app that merely shows how to link in MPOAuth and make use of it on the iPhone. I wrote this a while ago while testing, but have updated it now to demonstrate how to implement an MPOAuthAPIDelegate, use an inline UIWebView for user authorization, implement a custom URI handler to return control to your application and then finally make an authenticated request.</p>
<h3>MPOAuthAPIDelegate</h3>
<p>MPOAuthAPIDelegate allows an application to be a part of the OAuth authentication dance by providing a callback URL as well as choosing whether the user should automatically be taken to the authentication URL via the system&#8217;s default web browser.</p>
<h3>Callback URIs</h3>
<p>While custom callbacks URIs are a useful way for client side applications to return control to their application, many OAuth producers do not allow consumers to make use of them even for client applications. If you&#8217;re unable to get this to work it may be due to the fact that your OAuth producer does not allow it and doesn&#8217;t inform you of such. There&#8217;s also what I feel is a hacky solution for capturing url load requests and then returning the control to your application manually. This is a hack for the above problem so that you may use arbitrary domains like example.com to redirect.</p>
<h3>Setup</h3>
<p>In order to use MPOAuthMobile, you need to first configure it to connect to an OAuth endpoint and set your consumer key and secret in RootViewController.m lines 13 and 14.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p321"><td class="line_numbers"><pre>13
14
</pre></td><td class="code" id="p32code1"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#define kConsumerKey		@&quot;key&quot;</span>
<span style="color: #6e371a;">#define kConsumerSecret		@&quot;secret&quot;</span></pre></td></tr></table></div>

<p>Among the supported OAuth endpoints in MPOAuth is twitter, so you can set http://twitter.com as the baseURL used to create your instance of MPOAuthAPI on line 39-40 and it&#8217;ll automatically do everything you need.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p322"><td class="line_numbers"><pre>39
40
</pre></td><td class="code" id="p32code2"><pre class="objc" style="font-family:monospace;">	_oauthAPI <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>MPOAuthAPI alloc<span style="color: #002200;">&#93;</span> initWithCredentials<span style="color: #002200;">:</span>credentials
						 andBaseURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://twitter.com/&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<h3>Usage</h3>
<p>Once you&#8217;ve compiled the application in Xcode, it will install into the simulator or device and when it launches the OAuth dance will automatically commence by getting the unauthorized request token, and opening an inline webview for user authorization. Once you&#8217;ve provided the user credentials, the web view is animated off the display stack and the state updated again. At this stage you&#8217;re free to type in whatever method you&#8217;d like to perform on the remote endpoint. In this case I used <strong>/statuses/friends_timeline.xml</strong> to see my timeline.</p>
<h3>Download</h3>
<p>The code can be found in the mpaouthconnection project on google code under the <a title="MPOAuthMobile" href="http://code.google.com/p/mpoauthconnection/source/browse/#svn/trunk/MPOAuthMobile">MPOAuthMobile</a> subdirectory</p>
]]></content:encoded>
			<wfw:commentRss>http://matrixPointer.com/karl/posts/mpoauth-on-the-iphone-mpoauthmobile/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
