[OSM-dev] OAuth 401 Unauthorized

Christoph Bünte tiny-grasshopper at gmx.net
Fri May 28 15:47:59 BST 2010


Hi Andy,

Am 28.05.2010 um 12:40 schrieb Andy Allan:

> On Fri, May 28, 2010 at 11:02 AM, Christoph Bünte
> <tiny-grasshopper at gmx.net> wrote:
> 
>> This is my piece of ruby code, which is closely related to the OAuth example: http://wiki.openstreetmap.org/wiki/OAuth/Examples
> 
> I've updated the examples since the exact behaviour of the OAuth
> plugin seems to have changed slightly over the last 12 months.

Thx for the update, i wasn't sure which development server to use. Now it show the proper url.
> 
>> consumer = OAuth::Consumer.new(oauth_key, oauth_secret, :site => 'http://www.openstreetmap.org')
>> consumer.get_request_token
> 
> Please don't test your application with the live API! There are test
> APIs available on the development server, and for this you should be
> using http://api06.dev.openstreetmap.org, with a separate account,
> oauth token etc for that.

Ok, i signed up a new account on the development server. Registered the same app and got my key and secret.

> 
>> But the second line always failes with an exception. I have installed the oauth gem version 0.4.0
>> Are there any known issues?
>> 
>> I appreciate any kind of help, links and whatsoever. I wasn't able to find something on the net specific to OSM.
> 
> The only thing I can think of is that you're mixing up tokens issued
> from a development server against the real server, or there's a typo
> in your commands.

Now the exact the code with development key, secret and url works fine on the development machine.
consumer = OAuth::Consumer.new(development_key, development_secret, :site => 'http://api06.dev.openstreetmap.org')
consumer.get_request_token
=> #<OAuth::RequestToken:0x1033412b0 @params={:oauth_token=>"kVBuIp1lIbR1ggqCE0qwAQ" ...

But when i use my production credentials, it's not.
consumer = OAuth::Consumer.new(production_key, production_secret, :site => 'hhttp://www.openstreetmap.org')
consumer.get_request_token
=> OAuth::Unauthorized: 401 Unauthorized

I double checked, that i did not mix up key and secret by copy&pasting it from my user account oauth page.
I even signed up for a new account on http://www.openstreetmap.org and registered the same app as on the dvelopment server (http://api06.dev.openstreetmap.org). Copied key and secret: Bang, same error.

> If nothing else works, please start with the example as written on the
> wiki, get that working with a test account on api06.dev, and start
> modifiying from there. Post the whole code when you make the change
> that breaks it.

Can someone confirm, that oauth is working on the live system?

Thanks a lot,

Christoph



More information about the dev mailing list