connecting via OAuth::Consumer

3 views
Skip to first unread message

Dr Nic

unread,
Apr 24, 2009, 6:22:41 AM4/24/09
to CloudKit
The eternally hopeful part of me hoped that the following would work
for any cloudkit app:

@consumer = OAuth::Consumer.new('cloudkitconsumer','', { :site =>
'http://localhost:9292' })

But it returns an unhelpful 500 error.

It turns out that the default routes of an OAuth::Consumer
(e.g. :request_token_path=>"/oauth/request_token") and the routes
provided by CloudKit differ ("/oauth/request_tokens" instead).

Is it too late in the projects history for the cloudkit routes to
match the defaults of the oauth gem?

Otherwise, for anyone else, I think the following non-default options
allow an OAuth::Consumer connect to CloudKit:

@consumer = OAuth::Consumer.new('cloudkitconsumer','', { :site =>
'http://localhost:9292',
:authorize_path=>"/oauth/authorization", :access_token_path=>"/oauth/
access_tokens", :request_token_path=>"/oauth/request_tokens"})

The oauth gem defaults seem to be:

:request_token_path=>"/oauth/request_tokens",
:access_token_path=>"/oauth/access_tokens",
:authorize_path=>"/oauth/authorization",
:http_method=>:post,
:signature_method=>"HMAC-SHA1",
:oauth_version=>"1.0",
:scheme=>:header

Jon Crosby

unread,
Apr 24, 2009, 10:26:23 AM4/24/09
to clou...@googlegroups.com
On Fri, Apr 24, 2009 at 3:22 AM, Dr Nic <dr...@mocra.com> wrote:
>
> The eternally hopeful part of me hoped that the following would work
> for any cloudkit app:
>
> @consumer = OAuth::Consumer.new('cloudkitconsumer','', { :site =>
> 'http://localhost:9292' })

I share your optimism...

>
> But it returns an unhelpful 500 error.
>
> It turns out that the default routes of an OAuth::Consumer
> (e.g. :request_token_path=>"/oauth/request_token") and the routes
> provided by CloudKit differ ("/oauth/request_tokens" instead).
>
> Is it too late in the projects history for the cloudkit routes to
> match the defaults of the oauth gem?
>
> Otherwise, for anyone else, I think the following non-default options
> allow an OAuth::Consumer connect to CloudKit:
>
> @consumer = OAuth::Consumer.new('cloudkitconsumer','', { :site =>
> 'http://localhost:9292',
>  :authorize_path=>"/oauth/authorization", :access_token_path=>"/oauth/
> access_tokens", :request_token_path=>"/oauth/request_tokens"})
>
> The oauth gem defaults seem to be:
>
> :request_token_path=>"/oauth/request_tokens",
> :access_token_path=>"/oauth/access_tokens",
> :authorize_path=>"/oauth/authorization",
> :http_method=>:post,
> :signature_method=>"HMAC-SHA1",
> :oauth_version=>"1.0",
> :scheme=>:header

Your assessment and workaround are correct. Would you mind if I
tackled the issue of defaults from the opposite direction? If I added
support for OAuth Discovery to the OAuth gem, it would work
automatically with any host that supported the protocol by checking
its descriptor. If other committers aren't up for the idea, then I
won't waste any time making the quick change to CloudKit instead.

-Jon

Dr Nic Williams

unread,
Apr 26, 2009, 11:34:40 PM4/26/09
to clou...@googlegroups.com
If we patch OAuth gem where will the URIs-per-provider be cached? Just in memory I guess given you don't know who is using the oauth gem and want storage they have available.

Are there "recommended oauth URIs" in the oauth spec?

Nic
--
Dr Nic Williams
Mocra - Premier iPhone and Ruby on Rails Consultants
w - http://mocra.com
twitter - @drnic
skype - nicwilliams
e - dr...@mocra.com
p - +61 412 002 126 or +61 7 3102 3237

Jon Crosby

unread,
Apr 28, 2009, 12:58:28 PM4/28/09
to clou...@googlegroups.com
On Sun, Apr 26, 2009 at 8:34 PM, Dr Nic Williams <dr...@mocra.com> wrote:
> If we patch OAuth gem where will the URIs-per-provider be cached? Just in
> memory I guess given you don't know who is using the oauth gem and want
> storage they have available.

I would say in-memory would work at as starting point. Moneta might be
a good interface after that, as it would allow plugging in almost any
store as a back end. Additionally, by adding the expiration capability
from Moneta's API, the expiration listed in the OAuth descriptor could
be used for the cache expiration so that it would happen automatically
when needed.

> Are there "recommended oauth URIs" in the oauth spec?

There are no formal recommendations, but many implementers have used
the samples in the spec. The official take is that the URIs are an
implementation detail and that setting up clients to work with them
happens out-of-band. OAuth Discovery attempts to make it a non-issue.

-Jon
Reply all
Reply to author
Forward
0 new messages