<?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>Tommy Chheng &#187; oauth</title>
	<atom:link href="http://tommy.chheng.com/index.php/tag/oauth/feed/" rel="self" type="application/rss+xml" />
	<link>http://tommy.chheng.com</link>
	<description>All Things Programming!</description>
	<lastBuildDate>Wed, 11 Aug 2010 05:58:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Twitter OAuth Ruby Gem PIN-based Authentication API Change</title>
		<link>http://tommy.chheng.com/index.php/2009/08/twitter-oauth-ruby-gem-pin-based-authentication-api-change/</link>
		<comments>http://tommy.chheng.com/index.php/2009/08/twitter-oauth-ruby-gem-pin-based-authentication-api-change/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 19:08:07 +0000</pubDate>
		<dc:creator>tommy</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://tommy.chheng.com/?p=139</guid>
		<description><![CDATA[I have been using the moomerman-twitter_oauth gem for to allow users to login to our web app via Twitter Connect. Unfortunately, it stopped working when a change in the Twitter API happened. During the OAuth authentication process, instead of being redirected back to our web app, it would show a screen that said: "You've successfully [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using the moomerman-twitter_oauth gem for to allow users to login to our web app via Twitter Connect. Unfortunately, it stopped working when a change in the Twitter API happened. During the OAuth authentication process, instead of being redirected back to our web app, it would show a screen that said:</p>
<pre>"You've successfully granted access...enter the following PIN to complete the process"</pre>
<p>After browsing the net and getting help from the Twitter API team, I learned that Twitter recently made a change to their OAuth process to allow this PIN type authentication for applications.  See for more info: <a href="http://groups.google.com/group/twitter-development-talk/browse_thread/thread/472500cfe9e7cdb9/848f834227d3e64d?pli=1">http://groups.google.com/group/twitter-development-talk/browse_thread/thread/472500cfe9e7cdb9/848f834227d3e64d?pli=1</a></p>
<p>The oauth ruby gem defaults to using PIN-based process instead of the regular web app redirect process. To fix this, explicitly set the oauth_callback url parameter when getting the request token:</p>
<pre>    @twitter_client = TwitterOAuth::Client.new(
        :consumer_key =&gt; TWITTER_CONSUMER_KEY,
        :consumer_secret =&gt; TWITTER_CONSUMER_SECRET
    )
    request_token = @twitter_client.request_token(:oauth_callback =&gt; oauth_confirm_url)</pre>
<p>If you are getting a <em>(OAuth::Unauthorized) &#8220;401 Unauthorized&#8221;</em> error after adding the oauth_callback parameter, try altering your oauth callback method to explicitly state the oauth_verifier as well:</p>
<pre>
  def oauth_callback
    @twitter_client = TwitterOAuth::Client.new(
        :consumer_key => TWITTER_CONSUMER_KEY,
        :consumer_secret => TWITTER_CONSUMER_SECRET
    )

    @twitter_access_token = @twitter_client.authorize(
      session[:request_token],
      session[:request_token_secret],
      <img src='http://tommy.chheng.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> auth_verifier =>params[:oauth_verifier]
    )
</pre>
<p>Apparently, this was <a href="http://groups.google.com/group/twitter-development-talk/browse_thread/thread/1c48fedf4ae7ed52/5ac22db230c7a95a?lnk=gst&#038;q=oauth+pin#5ac22db230c7a95a">posted</a> on the Twitter API Development Group in late May, but it would have been nice if Twitter DMed every web app signed up on the twitter app list of the change.  I guess this is a warning for any Twitter API consumers to follow the dev list closely..</p>
]]></content:encoded>
			<wfw:commentRss>http://tommy.chheng.com/index.php/2009/08/twitter-oauth-ruby-gem-pin-based-authentication-api-change/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
