[OSM-dev] Basic http authentication with OpenStreetMap apis

Alberto Almagro albertoalmagro at gmail.com
Thu Jan 20 11:06:00 GMT 2011


Hello,

I'm developing an application that needs to connect to OpenStreetMap's
API (http://api.openstreetmap.org/ and also
http://api06.dev.openstreetmap.org/).

I use maven, hibernate, spring and tapestry. When I execute maven's
test phase, my application establishes connection successfully with
OSM only adding a header to the http request like the following:

Authorization: Basic bV9qb3NlbmhhbnNAd2fiLmRlOmJsdWVkaWFtb25k

The problems started when I included this use case in the web
interface, at the beggining it prompted an error telling me that I
didn't have credentials to connect... so I added the following code:

HttpClient client = new HttpClient();
                       client.getState().setCredentials(
                                       AuthScope.ANY,
                                       new
UsernamePasswordCredentials(cuentaOsm.getOsmLoginMail(),
cuentaOsm.getOsmClearPassword()));

And after that it prompts me the following error:

19-ene-2011 23:26:27
org.apache.commons.httpclient.auth.AuthChallengeProcessor
selectAuthScheme
INFO: basic authentication scheme selected
19-ene-2011 23:26:27 org.apache.commons.httpclient.HttpMethodDirector
processWWWAuthChallenge
INFO: Failure authenticating with BASIC 'Web
Password'@api06.dev.openstreetmap.org:80
50446 [1481353080 at qtp-730403186-0] ERROR
org.apache.tapestry5.services.TapestryModule.RequestExceptionHandler -
Processing of request failed with uncaught exception:
es.udc.gisapp.model.util.exceptions.ServiceException: HTTP error;
status code = 401
org.apache.tapestry5.runtime.ComponentEventException:
es.udc.gisapp.model.util.exceptions.ServiceException: HTTP error;
status code = 401 [at
classpath:es/udc/gisapp/web/pages/applicationservice/MigrarBdOsm.tml,
line 17]

I don't know what happends, maybe that 'Web Password' realm isn't
correct... I'm very confused... In the test phase all continues
working OK.

¿Any help please?

Thank you in advance,
Alberto



More information about the dev mailing list