<?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>Steve Reynolds Blog &#187; Basic Authentication</title>
	<atom:link href="http://www.reynoldsftw.com/tag/basic-authentication/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.reynoldsftw.com</link>
	<description>Being Generalist.</description>
	<lastBuildDate>Fri, 03 Sep 2010 19:00:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using xAuth, an alternate OAuth from Twitter</title>
		<link>http://www.reynoldsftw.com/2010/03/using-xauth-an-alternate-oauth-from-twitter/</link>
		<comments>http://www.reynoldsftw.com/2010/03/using-xauth-an-alternate-oauth-from-twitter/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 13:00:22 +0000</pubDate>
		<dc:creator>Steve Reynolds</dc:creator>
				<category><![CDATA[Chirpie]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Social-Web]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Basic Authentication]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[xAuth]]></category>

		<guid isPermaLink="false">http://www.reynoldsftw.com/?p=1662</guid>
		<description><![CDATA[In the last week Twitter did something interesting in order to quell the increasing noise from mobile and desktop app developers, that was &#8211; introducing xAuth to the wider web. Back in early February the Twitter API team announced the new xAuth authentication mechanism. Twitter hope it will fill the void of terrible user experiences [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2010%2F03%2Fusing-xauth-an-alternate-oauth-from-twitter%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2010%2F03%2Fusing-xauth-an-alternate-oauth-from-twitter%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>In the last week <strong>Twitter </strong>did something interesting in order to quell the increasing noise from mobile and desktop app developers, that was &#8211; introducing <strong>xAuth</strong> to the wider web. Back in early February the Twitter API team announced the new xAuth authentication mechanism. Twitter hope it will fill the void of terrible user experiences mixed with web contexts into desktop and mobile apps experienced when using current authentication preference, <strong>OAuth</strong>.</p>
<h3>Basic Authentication</h3>
<p>Back when Twitter first launched it&#8217;s API they had what&#8217;s called Basic Authentication. A user of the API had to make all API calls directly with their username and password. iPhone apps such as Tweetie, Twitterrific and Birdfeed all use basic authentication. I myself used basic auth in <a href="http://chirpieapp.com" target="_blank">Chirpie</a> when I launched it 1 week ago.</p>
<p>From a dev perspective, basic auth is really simple &#8211; just make sure you store the username and password for an account, and re-use on every API call. However, Twitter deemed that from a security perspective, it wasn&#8217;t a great idea to be using the user&#8217;s credentials every single time they interacted with the API, they therefore decided to use <strong>OAuth</strong>. In addition, it&#8217;s required for any application that uses basic auth to store the username and password for re-use between sessions. Another no no apparently&#8230;</p>
<p>Twitter are now about to kill of basic authentication. Check out <a href="http://www.countdowntooauth.com/">http://www.countdowntooauth.com/</a></p>
<div id="attachment_1731" class="wp-caption aligncenter" style="width: 490px"><img class="size-full wp-image-1731" title="twitter-basic" src="http://www.reynoldsftw.com/wp-content/uploads/2010/03/twitter-basic.png" alt="Twitter Basic Auth Death Clock" width="480" height="182" /><p class="wp-caption-text">Twitter Basic Auth Death Clock</p></div>
<h3><strong>OAuth</strong></h3>
<p>I won&#8217;t go into the deep details of OAuth, but the basic premise is this, an application gets a request token, and sends the user off to the source website (in this case Twitter) for a set of authorized tokens which it gives back to the application, and subsequently uses to exchange with the API instead of the user:pass :</p>
<div id="attachment_1668" class="wp-caption aligncenter" style="width: 462px"><img class="size-full wp-image-1668" title="OAuth Process" src="http://www.reynoldsftw.com/wp-content/uploads/2010/02/Screen-shot-2010-02-28-at-08.52.08.png" alt="OAuth Process" width="452" height="124" /><p class="wp-caption-text">OAuth Process</p></div>
<p>The problem with this is the <strong><em>&#8220;via web&#8221;</em></strong> part. For mobile and desktop apps, you have to leave the comfort of your application, and into a web interface in order to authorize the request. In addition to this, Twitter penalised anyone using basic authentication by stopping them from publishing their application name unless using OAuth (hence the developer outcry for some months). Example:</p>
<div id="attachment_1665" class="wp-caption aligncenter" style="width: 243px"><a href="http://chirpieapp.com"><img class="size-full wp-image-1665  " title="Twitter Basic Auth Vs OAuth/xAuth" src="http://www.reynoldsftw.com/wp-content/uploads/2010/02/HelloWorldExample.png" alt="Twitter Basic Auth Vs OAuth" width="233" height="80" /></a><p class="wp-caption-text">Twitter Basic Auth Vs OAuth/xAuth</p></div>
<p>It&#8217;s worth noting here, that in the old days basic auth apps could publish tweets using &#8220;via <em>application name</em>&#8220;, however early in 2009 Twitter stopped accepting registrations for basic auth applications, which is why some basic auth apps still come from their app name, like Tweetie, where more recent ones come from &#8220;web&#8221;.</p>
<p>On iPhone, leaving the comfort of a native app into a web interface (which was until recently not optimized for mobile) was a huge loss &#8211; therefore most iPhone devs from recent times opted for basic auth in order to keep a good user experience.</p>
<h3>Enter xAuth</h3>
<p>So xAuth is here to save the day&#8230; xAuth takes some fundamentals from OAuth in the sense that you still use your authorised tokens to interact with the API, however it&#8217;s the process of getting that set of authorised tokens that has changed. Basic auth developers can now exchange the username and password of their users for an authorised token set in one API call. No web interface required. Essentially:</p>
<div id="attachment_1664" class="wp-caption aligncenter" style="width: 209px"><img class="size-full wp-image-1664" title="xAuth Process" src="http://www.reynoldsftw.com/wp-content/uploads/2010/02/Screen-shot-2010-02-28-at-08.20.28.png" alt="xAuth Process" width="199" height="113" /><p class="wp-caption-text">xAuth Process</p></div>
<p style="text-align: left;">This stumps alot of people at first, there&#8217;s no process involved to get a request token, that&#8217;s all out of the door &#8211; it&#8217;s simply get the user&#8217;s credentials, make an API call, receive authorised tokens in return.</p>
<p style="text-align: left;">The downside of this is that the application is interacting directly with the username and password (in the same way basic auth did), so in essence is losing a large chunk of the security effect of OAuth (OAuth apps never see the username and password of the user directly, only the tokens).</p>
<p style="text-align: left;">There are alot of arguments around the web on the effectiveness of xAuth &#8211; to me it seems like its just basic authentication with a bit of extra security because each API call isn&#8217;t using the user:pass every time &#8211; in fact, to even associate it with OAuth for me is a little bit crazy.</p>
<p style="text-align: left;">That said, <strong><span style="text-decoration: underline;">I am extremely happy</span></strong>. As a recent iPhone app developer, I was gutted to find that I could no longer register <a href="http://chirpieapp.com" target="_blank">Chirpie</a> as a basic auth app with Twitter, and subsequently couldn&#8217;t promote the use of it within Twitter unless I used OAuth.</p>
<h3>Using xAuth</h3>
<p style="text-align: left;">Using xAuth couldn&#8217;t be simpler actually. First off though, you need to send an email to api@twitter.com and ask them to register your OAuth application to use xAuth. Once approved (you&#8217;ll get an email at time of writing) you make a call to the API method <strong>&#8220;</strong><em><strong>https://api.twitter.com/oauth/access_token&#8221;</strong></em> and simply send it 3 parameters:</p>
<ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2em; font-weight: inherit; font-style: inherit; font-size: 13px; font-family: inherit; vertical-align: baseline; padding: 0px; border: 0px initial initial;">
<li style="font-weight: inherit; font-style: inherit; font-size: 13px; font-family: inherit; vertical-align: baseline; padding: 0px; margin: 0px; border: 0px initial initial;"><span style="font-weight: inherit; font-style: inherit; font-size: 13px; font-family: 'Courier New'; vertical-align: baseline; padding: 0px; margin: 0px; border: 0px initial initial;">x_auth_username</span> -  The username of the user.</li>
<li style="font-weight: inherit; font-style: inherit; font-size: 13px; font-family: inherit; vertical-align: baseline; padding: 0px; margin: 0px; border: 0px initial initial;"><span style="font-weight: inherit; font-style: inherit; font-size: 13px; font-family: 'Courier New'; vertical-align: baseline; padding: 0px; margin: 0px; border: 0px initial initial;">x_auth_password</span> &#8211; The password of the user</li>
<li style="font-weight: inherit; font-style: inherit; font-size: 13px; font-family: inherit; vertical-align: baseline; padding: 0px; margin: 0px; border: 0px initial initial;"><span style="font-weight: inherit; font-style: inherit; font-size: 13px; font-family: 'Courier New'; vertical-align: baseline; padding: 0px; margin: 0px; border: 0px initial initial;">x_auth_mode</span> &#8211; Set this value to &#8220;client_auth&#8221; (without the quotes).</li>
</ul>
<p>This one method then returns you the authorised access tokens in the same way the same method does for OAuth. You should store the tokens as they do not expire, and reuse the tokens for any subsequent API calls. The password can effectively be forgotten after the authorised access tokens are received (unless you need them for third party sites such as TwitPic etc..).</p>
<p>It really is that simple, just one step. As long as you remember this key point (that it&#8217;s one API call, no request tokens needed etc), you will be setup really quickly. The Twitter documents aren&#8217;t so clear on this, and hopefully they will clarify a bit better shortly.</p>
<p>I managed to get xAuth implemented into <a href="http://chirpieapp.com" target="_blank">Chirpie</a> in about an hour, and submitted to the App Store. Such a small change, which I hope will make a huge difference to the effectiveness of <a href="http://chirpieapp.com" target="_blank">Chirpie</a> in Twitter.</p>
<h3>Update &#8211; xAuthTwitterEngine</h3>
<p>For those hoping to get xAuth working on an iPhone, Aral Balkan <a href="http://aralbalkan.com/3133" target="_blank">has just launched xAuthTwitterEngine</a>, which is an update to the excellent <a href="http://mattgemmell.com/2008/02/22/mgtwitterengine-twitter-from-cocoa" target="_blank">MGTwitterEngine</a> from Matt Gemmell, via an <a href="http://github.com/bengottlieb/Twitter-OAuth-iPhone" target="_blank">OAuth implementation</a> of that by Ben Gottlieb.</p>
<p>I haven&#8217;t used xAuthTwitterEngine in <a href="http://chirpieapp.com" target="_blank">Chirpie</a>, however my implementation was exactly the same, a re use of Ben&#8217;s OAuth code, removing the web authentication interface and replacing with a user:pass API call. I just wasn&#8217;t brave enough to release it to the world as I&#8217;m still learning! Anyway, have fun!
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2010%2F03%2Fusing-xauth-an-alternate-oauth-from-twitter%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.reynoldsftw.com%2F2010%2F03%2Fusing-xauth-an-alternate-oauth-from-twitter%2F&amp;source=SteveReynolds&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.reynoldsftw.com/2010/03/using-xauth-an-alternate-oauth-from-twitter/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>
