<?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; API</title>
	<atom:link href="http://matrixPointer.com/karl/posts/tag/api/feed" rel="self" type="application/rss+xml" />
	<link>http://matrixPointer.com/karl</link>
	<description></description>
	<lastBuildDate>Thu, 30 Dec 2010 17:40:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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><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><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>
		<item>
		<title>Introducing MPOAuthConnection</title>
		<link>http://matrixPointer.com/karl/posts/introducing-mpoauthconnection</link>
		<comments>http://matrixPointer.com/karl/posts/introducing-mpoauthconnection#comments</comments>
		<pubDate>Fri, 12 Dec 2008 09:50:04 +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[OAuth]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[Social]]></category>

		<guid isPermaLink="false">http://matrixPointer.com/karl/?p=6</guid>
		<description><![CDATA[Introducing MPOAuthConnectionm an easy to use OAuth API allowing you to connect to web services.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve wanted to do anything with WebServices recently you&#8217;ve likely encountered OAuth, the open specification for client server data transmission. In a nutshell OAuth allows a desktop or web application a secure method by which to obtain user credentials for an online service without ever having to actually get the user&#8217;s username or password directly. It protects users credentials since they don&#8217;t need to give them out to multiple parties, and improves site security by giving users the tools with which to turn off the access of applications and services to their data.</p>
<p>Due to the proliferation of these services a common need exists to quickly be able to connect to to them without having to write yet more complicated code to do this when you just want to build your snazzy new application. Since I happen to enjoy using and writing APIs I took it upon myself to write one for OAuth for Mac and iPhone Cocoa applications. To this end, I&#8217;ve created the MPOAuthConnection set of classes that make it trivial to talk to these applications.</p>
<p>At the high level you merely need to tell MPOAuthAPI about the URL to your intended web service and give it your consumer key and secret and it will take care of the rest of the work of authenticating, retrieving access keys, and storing them on the user keychain on Mac OS X and iPhone*. There is a sparse delegate API for you to take part in the authentication sequence if necessary. Once authenticated you can perform method requests asynchronously or synchronously on the remote API using -performMethod:withTarget:action: or -dataForMethod: respectively.</p>
<p>The API is built in a layered way that allows you to, if so interested, jump in at lower levels for more direct control of the server communication and interact more directly with the classes doing the work, but so far I don&#8217;t believe this will very often be necessary. I&#8217;m using this code in a current project so it works well for me, and I&#8217;ve fixed the bugs I&#8217;ve encountered so far. I&#8217;m hoping you guys can find others, but of course if you don&#8217;t run into any that&#8217;s great too.</p>
<p>This code was built using the OAuth Core spec as a reference, along with the Yahoo! OAuth guide and the Google OAuth guide. It&#8217;s been tested by myself connecting to a few of the Yahoo! and Google OAuth services. It includes code excerpts from Jonathan Wight and Steve Reid for base64 encoding and HMAC-SHA1 hashing.</p>
<p><a href="http://code.google.com/p/mpoauthconnection/">MPOAuthConnection on Google Code</a></p>
<p>Edit: Properly refer to OAuth as OAuth</p>
]]></content:encoded>
			<wfw:commentRss>http://matrixPointer.com/karl/posts/introducing-mpoauthconnection/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

