<?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>dannyroa &#187; Django</title>
	<atom:link href="http://www.dannyroa.com/category/django-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dannyroa.com</link>
	<description>tech, music, travel</description>
	<lastBuildDate>Thu, 12 Jan 2012 19:23:02 +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>Sign In With Google &amp; Get User Info from Google+ Profile</title>
		<link>http://www.dannyroa.com/2011/09/26/sign-in-with-google-get-user-info-from-google-profile/</link>
		<comments>http://www.dannyroa.com/2011/09/26/sign-in-with-google-get-user-info-from-google-profile/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 00:13:59 +0000</pubDate>
		<dc:creator>dannyr</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.dannyroa.com/?p=260</guid>
		<description><![CDATA[At the start, authentication options for our site Burp (http://goburp.com) include regular email/password &#38; Facebook Connect. For quite a while, I&#8217;ve been wanting to integrate Google Accounts Authentication. I&#8217;ve looked at django-socialauth (http://social.matiasaguirre.net/) but it uses OpenID. I prefer a pure OAuth2 implementation similar to what Facebook &#38; FourSquare uses. Looking at Google&#8217;s documentation, it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>At the start, authentication options for our site Burp (<a href="http://goburp.com">http://goburp.com</a>) include regular email/password &amp; Facebook Connect. For quite a while, I&#8217;ve been wanting to integrate Google Accounts Authentication.</p>
<p>I&#8217;ve looked at django-socialauth (<a href="http://social.matiasaguirre.net/">http://social.matiasaguirre.net/</a>) but it uses OpenID. I prefer a pure OAuth2 implementation similar to what Facebook &amp; FourSquare uses.</p>
<p>Looking at Google&#8217;s documentation, it&#8217;s not easy to figure out. The Federated Login (<a href="http://code.google.com/apis/accounts/docs/OpenID.html">http://code.google.com/apis/accounts/docs/OpenID.html</a>) is just a pain to implement. </p>
<p>Google recently streamlined their API &amp; they have libraries for every major programming language. Implementation is too complex though which includes a separate model to store credentials (see <a href="http://code.google.com/p/google-api-python-client/source/browse/oauth2client/django_orm.py">http://code.google.com/p/google-api-python-client/source/browse/oauth2client/django_orm.py</a>).</p>
<p>OAuth2 implementation by FourSquare &amp; Facebook is so simple that there must be a way to do that with Google: Get an authorization url, Get a code back &amp; Exchange that for an access token. Then use that access token to access the API. Google has documentation for OAuth2 but it actually lacks information on how to get a user&#8217;s email address (<a href="http://code.google.com/apis/accounts/docs/OAuth2.html">http://code.google.com/apis/accounts/docs/OAuth2.html</a>).</p>
<p>After scouring the internets, I finally stumbled into a PHP implementation. It has the scope (https://www.googleapis.com/auth/userinfo#email) that I&#8217;ve been looking for which is missing from Google&#8217;s documentation (<a href="http://code.google.com/apis/gdata/faq.html#AuthScopes">http://code.google.com/apis/gdata/faq.html#AuthScopes</a>). The OAuth2 steps are pretty standard except that the access token can be added to the header of the request instead of as a parameter in the url (<a href="http://code.google.com/apis/accounts/docs/OAuth2.html#CallingAnAPI">http://code.google.com/apis/accounts/docs/OAuth2.html#CallingAnAPI</a>).</p>
<p>This, however, only gets me the email address of the user. I also want to get the user&#8217;s name, location, gender, etc.</p>
<p>Luckily, Google just opened up an API for Google+. </p>
<p>By adding the scope &#8211; https://www.googleapis.com/auth/plus.me &#8211; to the OAuth2 call, our app will have access to the public info the user provided in their Google+ Profile. The People:get method (<a href="http://developers.google.com/+/api/latest/people/get">http://developers.google.com/+/api/latest/people/get</a>) will provide you with the user&#8217;s Display Name, Location, and Profile Picture Url among others.</p>
<p>You can view the sample Django project at <a href="https://github.com/dannyroa/sign-in-with-google">https://github.com/dannyroa/sign-in-with-google</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dannyroa.com/2011/09/26/sign-in-with-google-get-user-info-from-google-profile/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Default values when creating new row in Django Admin</title>
		<link>http://www.dannyroa.com/2010/06/20/default-values-when-creating-new-row-in-django-admin/</link>
		<comments>http://www.dannyroa.com/2010/06/20/default-values-when-creating-new-row-in-django-admin/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 02:56:08 +0000</pubDate>
		<dc:creator>dannyr</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://blog.dannyroa.com/?p=173</guid>
		<description><![CDATA[In one of the apps I'm developing at work, I wanted to make it easy for our content admins to create a new row in the Django Admin. Most of the time, they need to create a new row that is associated to their own user account. It would save them a couple of steps if the user field is set to a default value]]></description>
			<content:encoded><![CDATA[<p>In one of the apps I&#8217;m developing at work, I wanted to make it easy for our content admins to create a new row in the Django Admin. Most of the time, they need to create a new row that is associated to their own user account. It would save them a couple of steps if the user field is set to a default value. Thanks to my coworker, <a title="Dave Ziegler" href="http://twitter.com/david_ziegler">Dave Ziegler</a>,  for helping me  figure this out.</p>
<p><script src="http://gist.github.com/446318.js"></script></p>
<p><em>Extra tip: </em><br />
use raw_id_fields in Django Admin. This is especially useful when you have plenty of users. What you&#8217;ll see is the id of the user in the text field with a link to look up users next to it (instead of a dropdown containing usernames of all the users).<br />
If you don&#8217;t set the raw_id_fields, it would take a long time for Django Admin to load the &#8216;Change &#8216; page since all the users in your database needs to be loaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dannyroa.com/2010/06/20/default-values-when-creating-new-row-in-django-admin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

