2nd step of Oauth processus does not work on a local osm web site

Jean-Claude Jouffre jean-claude.jouffre at univ-smb.fr
Mon Dec 5 16:13:17 UTC 2016


Hello,

I would like to set up a configuration to modify data inside the OSM web 
site database using the API, according to this protocol :
http://wiki.openstreetmap.org/wiki/OAuth

I use a derived version of the russian PHP example, described here: 
http://wiki.openstreetmap.org/wiki/OAuth/examples

The program is able to read data on the dev OSM web site 
(http://api06.dev.openstreetmap.org).

You can see the code here :
https://help.openstreetmap.org/questions/52854/impossible-to-write-using-api-and-oauth

But when I try to do the same on my local osm web site, it fails on the 
access_token page, with a 401 (unauthorized) error at the rails console.

1st call http://mysite/oauth/request_token

it worked perfectly :
- the rails server did an insert in oauth_tokens table with a good 
couple (key+secret), the type is 'RequestToken' and authorized_at and
invalidated_at are null
- the return status of the call was 200 and the program received the 
token (TheGoodValue) and the secret

2nd call http://mysite/oauth/access_token/oauth_token=TheGoodValue

- it sticked on this page with a blank page
- at the rails console, we can see :
   Started GET "/oauth/access_token?oauth_token=TheGoodValue
   SELECT  "oauth_tokens".* FROM "oauth_tokens" WHERE
     "oauth_tokens"."type" IN ('Oauth2Token') AND (invalidated_at IS NULL
     and authorized_at IS NOT NULL and token =
    'TheGoodValue')  ORDER BY "oauth_tokens"."id" ASC LIMIT 1
   Processing by OauthController#access_token as HTML
   Parameters:
    {"oauth_token"=>"TheGoodValue"}
   Rendered text template (0.0ms)
   Completed 401 Unauthorized in 1ms (Views: 0.5ms | ActiveRecord: 0.0ms)

Of course, the record of the step1 has 2 bad values, so the SQL :
. type equals 'RequestToken' instead of 'Oauth2Token'
. authorized_at is null instead of not null

-> Can you please help me (again) to set up a good API configuration ?

Thanks a lot

JC



More information about the rails-dev mailing list