<?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>cakebaker &#187; oauth</title>
	<atom:link href="http://cakebaker.42dh.com/tags/oauth/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 20 Dec 2011 15:29:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>2-legged vs. 3-legged OAuth</title>
		<link>http://cakebaker.42dh.com/2011/01/10/2-legged-vs-3-legged-oauth/</link>
		<comments>http://cakebaker.42dh.com/2011/01/10/2-legged-vs-3-legged-oauth/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 17:30:25 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[oauth]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1471</guid>
		<description><![CDATA[From emails I receive it seems like there is a bit of confusion about what the terms 2-legged OAuth and 3-legged OAuth mean. I hope I can clear up this confusion with this article (and don&#8217;t contribute more to the confusion&#8230;). In short, they describe two different usage scenarios of OAuth involving two respectively three [...]]]></description>
			<content:encoded><![CDATA[<p>From emails I receive it seems like there is a bit of confusion about what the terms <strong>2-legged OAuth</strong> and <strong>3-legged OAuth</strong> mean. I hope I can clear up this confusion with this article (and don&#8217;t contribute more to the confusion&#8230;).</p>
<p>In short, they describe two different usage scenarios of <a href="http://oauth.net/">OAuth</a> involving two respectively three parties.</p>
<p><a href="http://tools.ietf.org/html/rfc5849">3-legged OAuth</a> describes the scenario for which OAuth was originally developed: a resource owner wants to give a client access to a server without sharing his credentials (i.e. username/password). A typical example is a user (resource owner) who wants to give a third-party application (client) access to his Twitter account (server). </p>
<p>On a conceptual level it works in the following way:</p>
<ul>
<li>Client has signed up to the server and got his client credentials (also known as &#8220;consumer key and secret&#8221;) ahead of time</li>
<li>User wants to give the client access to his protected resources on the server</li>
<li>Client retrieves the temporary credentials (also known as &#8220;request token&#8221;) from the server</li>
<li>Client redirects the resource owner to the server</li>
<li>Resource owner grants the client access to his protected resources on the server</li>
<li>Server redirects the user back to the client</li>
<li>Client uses the temporary credentials to retrieve the token credentials (also known as &#8220;access token&#8221;) from the server</li>
<li>Client uses the token credentials to access the protected resources on the server</li>
</ul>
<p><a href="http://oauth.googlecode.com/svn/spec/ext/consumer_request/1.0/drafts/2/spec.html">2-legged OAuth</a>, on the other hand, describes a typical client-server scenario, without any user involvement. An example for such a scenario could be a local Twitter client application accessing your Twitter account.</p>
<p>On a conceptual level 2-legged OAuth simply consists of the first and last steps of 3-legged OAuth:</p>
<ul>
<li>Client has signed up to the server and got his client credentials (also known as &#8220;consumer key and secret&#8221;)</li>
<li>Client uses his client credentials (and empty token credentials) to access the protected resources on the server</li>
</ul>
<p>Above I used Twitter as an example, though strictly speaking, they don&#8217;t use 2-legged OAuth, but a variant of it. They not only provide the client credentials but also the token credentials (see also <a href="http://dev.twitter.com/pages/oauth_single_token">Using one access token with OAuth</a>).</p>
<p>As you have seen, 2-legged OAuth is nothing new, it is simply using OAuth in a different scenario than it was designed for. And hence you can use (almost?) all existing OAuth libraries for 2-legged OAuth, too. </p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2011/01/10/2-legged-vs-3-legged-oauth/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Using OAuth-enabled APIs with CakePHP</title>
		<link>http://cakebaker.42dh.com/2008/09/01/using-oauth-enabled-apis-with-cakephp/</link>
		<comments>http://cakebaker.42dh.com/2008/09/01/using-oauth-enabled-apis-with-cakephp/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 14:44:32 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[oauth]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=769</guid>
		<description><![CDATA[A growing number of APIs support OAuth, i.e. it is possible to give service A access to service B without giving B&#8217;s username/password to A. In this article I&#8217;m going to show you how to use OAuth-enabled APIs with CakePHP (and the OAuth consumer component I have written). First, there are some preparations necessary, namely [...]]]></description>
			<content:encoded><![CDATA[<p>A growing number of APIs support <a href="http://oauth.net">OAuth</a>, i.e. it is possible to give service A access to service B without giving B&#8217;s username/password to A. In this article I&#8217;m going to show you how to use OAuth-enabled APIs with CakePHP (and the OAuth consumer component I have written).</p>
<p>First, there are some preparations necessary, namely the download of the required files:</p>
<ul>
<li>Get the <a href="http://cakebaker.42dh.com/downloads/oauth-component-for-cakephp/">OAuth component</a> and place its content in &#8220;app/controllers/components&#8221;</li>
<li>Get the <a href="http://oauth.googlecode.com/svn/code/php/OAuth.php">OAuth library</a> and put it in &#8220;vendors/OAuth&#8221;</li>
<li>Set the security level in app/config/core.php to &#8220;low&#8221; (thanks to <a href="http://www.intertwinesys.com/">Bryan Young</a> for mentioning in the comments)</li>
</ul>
<p>The next step is to register your application at the service provider (e.g. <a href="http://fireeagle.yahoo.net/developer">Yahoo&#8217;s Fire Eagle</a>) to get consumer key and consumer secret. Those values are then stored in a class called FireEagleConsumer if we go on using Fire Eagle as example service provider in this article:</p>
<pre>
<code>// app/controllers/components/oauth_consumers/fire_eagle_consumer.php
class FireEagleConsumer extends AbstractConsumer {
    public function __construct() {
        parent::__construct('THE KEY', 'THE SECRET');
    }
}</code>
</pre>
<p>This class is then used by the component to access consumer key and secret.</p>
<p>Using an OAuth-enabled API consists of four steps:</p>
<ul>
<li>Get RequestToken</li>
<li>Authorize RequestToken</li>
<li>Exchange RequestToken for AccessToken</li>
<li>Access the API using the AccessToken</li>
</ul>
<p>In the ideal case the first three steps are performed once. But it is also possible that for example the service provider expires the AccessToken after some time, and so those steps have to be repeated.</p>
<p>Anyway, let&#8217;s have a look at how those steps look in code. We start with getting the RequestToken:</p>
<pre>
<code>// app/controller/oauth_consumer_example_controller.php
class OauthConsumerExampleController extends AppController {
    public $uses = array();
    public $components = array('OauthConsumer');
	
    public function index() {
        $requestToken = $this-&gt;OauthConsumer-&gt;getRequestToken('FireEagle', 'https://fireeagle.yahooapis.com/oauth/request_token');
        $this-&gt;Session-&gt;write('requestToken', $requestToken);
    }
}</code>
</pre>
<p>The code is probably self-explanatory, we have to add the component to the $components array, and then we get the RequestToken from the specified url (while writing this I just realized it would make sense to move the url to the FireEagleConsumer class&#8230;).</p>
<p>The next step is simple: we have to redirect the user to the authorize page of the service provider:</p>
<pre>
<code>// app/controller/oauth_consumer_example_controller.php
class OauthConsumerExampleController extends AppController {
    public $uses = array();
    public $components = array('OauthConsumer');
	
    public function index() {
        $requestToken = $this-&gt;OauthConsumer-&gt;getRequestToken('FireEagle', 'https://fireeagle.yahooapis.com/oauth/request_token');
        $this-&gt;Session-&gt;write('requestToken', $requestToken);
        $this-&gt;redirect('http://fireeagle.yahoo.net/oauth/authorize?oauth_token='.$requestToken-&gt;key);
    }
}</code>
</pre>
<p>After the RequestToken is authorized, we get redirected to a callback url we specified while registering the application. We can now exchange the authorized RequestToken for an AccessToken:</p>
<pre>
<code>// app/controller/oauth_consumer_example_controller.php
class OauthConsumerExampleController extends AppController {
    public $uses = array();
    public $components = array('OauthConsumer');

    ...

    public function callback() {
        $requestToken = $this-&gt;Session-&gt;read('requestToken');
        $accessToken = $this-&gt;OauthConsumer-&gt;getAccessToken('FireEagle', 'https://fireeagle.yahooapis.com/oauth/access_token', $requestToken);
    }
}</code>
</pre>
<p>In a real use case you would also save the data of the AccessToken (key and secret) to the database, so you don&#8217;t have to perform all those steps every time you want to call the API. </p>
<p>The last step is to call the API, in this example to get the latest location of the user:</p>
<pre>
<code>// app/controller/oauth_consumer_example_controller.php
class OauthConsumerExampleController extends AppController {
    public $uses = array();
    public $components = array('OauthConsumer');

    ...

    public function callback() {
        $requestToken = $this-&gt;Session-&gt;read('requestToken');
        $accessToken = $this-&gt;OauthConsumer-&gt;getAccessToken('FireEagle', 'https://fireeagle.yahooapis.com/oauth/access_token', $requestToken);
        $data = $this-&gt;OauthConsumer-&gt;get('FireEagle', $accessToken-&gt;key, $accessToken-&gt;secret, 'https://fireeagle.yahooapis.com/api/0.1/user');
        // do something with the data
    }
}</code>
</pre>
<p>That&#8217;s it. Feedback is welcome!</p>
<p>Update 2008-09-15: Slightly adapted for new version of the component.<br />
Update 2009-01-14: Adding hint about security level.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/09/01/using-oauth-enabled-apis-with-cakephp/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
		<item>
		<title>OpenID versus OAuth from the user&#8217;s perspective</title>
		<link>http://cakebaker.42dh.com/2008/04/01/openid-versus-oauth-from-the-users-perspective/</link>
		<comments>http://cakebaker.42dh.com/2008/04/01/openid-versus-oauth-from-the-users-perspective/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 15:25:47 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[oauth]]></category>
		<category><![CDATA[openid]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=592</guid>
		<description><![CDATA[In this article I want to show the differences between OpenID and its younger cousin OAuth by providing for each a typical user scenario. First the scenario for OpenID: User wants to access his account on example.com example.com (the &#8220;Relying Party&#8221; in OpenID lingo) asks the user for his OpenID User enters his OpenID example.com [...]]]></description>
			<content:encoded><![CDATA[<p>In this article I want to show the differences between <a href="http://openid.net">OpenID</a> and its younger cousin <a href="http://oauth.net">OAuth</a> by providing for each a typical user scenario.</p>
<p>First the scenario for OpenID:</p>
<ul>
<li>User wants to access his account on example.com</li>
<li>example.com (the &#8220;Relying Party&#8221; in OpenID lingo) asks the user for his OpenID</li>
<li>User enters his OpenID</li>
<li>example.com redirects the user to his OpenID provider</li>
<li>User authenticates himself to the OpenID provider</li>
<li>OpenID provider redirects the user back to example.com</li>
<li>example.com allows the user to access his account</li>
</ul>
<p>And now the scenario for OAuth:</p>
<ul>
<li>User is on example.com and wants to import his contacts from mycontacts.com</li>
<li>example.com (the &#8220;Consumer&#8221; in OAuth lingo) redirects the user to mycontacts.com (the &#8220;Service Provider&#8221;)</li>
<li>User authenticates himself to mycontacts.com (which can happen by using OpenID)</li>
<li>mycontacts.com asks the user whether he wants to authorize example.com to access his contacts</li>
<li>User makes his choice</li>
<li>mycontacts.com redirects the user back to example.com</li>
<li>example.com retrieves the contacts from mycontacts.com</li>
<li>example.com informs the user that the import was successful</li>
</ul>
<p>From those scenarios we can see that OpenID is about <a href="http://en.wikipedia.org/wiki/Authentication">authentication</a> (i.e. I can identify myself with an url) whereas OAuth is about <a href="http://en.wikipedia.org/wiki/Authorization">authorization</a> (i.e. I can grant permission to access my data on some website to another website, without providing this website the authentication information for the original website).</p>
<p>I hope this helps to keep apart those two standards :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2008/04/01/openid-versus-oauth-from-the-users-perspective/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

