The Downscaling Portal RESTful API is token based authentication. That means, the user has to include a token in every request.
Climate4Impact has an existing account into the Downscaling Portal. With the credentials provided is very simple to authenticate and get the token.
curl -i -X POST -d username=your_username -d password=your_password http://meteo.unican.es/dp/rest/authenticate
Success
HTTP/1.1 201 Created Date: Mon, 24 Mar 2014 08:59:04 GMT token: your_token Content-Length: 0 Content-Type: text/plain
The API allows the manager to create users who have the same experiments as him and this users will be attached to the manager. Thus, users can be added, listed and removed from the DPRA Climate4Impact service.
In order to clarify how to use the API quickly, we are going to follow an example step by step.
curl -i -H "Accept: application/json" -H "Content-type: application/json" -H "token: your_token" -X POST -d "{\"username\": \"pcmdi9.llnl.gov.openid.vegasm\", \"email\": \"vegasm@unican.es\", \"openID\": \"https://pcmdi9.llnl.gov/openid/vegasm\"}" http://meteo.unican.es/dp/rest/users
Response
HTTP/1.1 201 Created Date: Mon, 24 Mar 2014 09:08:17 GMT Content-Length: 0 Content-Type: text/plain
If the request generates an exception or something is missing, an error will be shown. Note: In some cases, it is possible that the character " has not to be escaped.
curl -i -H "token: your_token" http://meteo.unican.es/dp/rest/users
Success
HTTP/1.1 200 OK Date: Mon, 24 Mar 2014 08:59:48 GMT Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked {"responseCode":"success","message":"List of users retrieved","values":[{"username":"pcmdi9.llnl.gov.openid.vegasm","password":null,"email":"vegasm@unican.es","openID":"pcmdi9.llnl.gov.openid.vegasm"}]}
curl -i -H "Accept: application/json" -H "Content-type: application/json" -H "token: your_token" -X DELETE http://meteo.unican.es/dp/rest/users/pcmdi9.llnl.gov.openid.vegasm
Success
HTTP/1.1 200 OK Date: Mon, 24 Mar 2014 09:00:59 GMT Content-Length: 0 Content-Type: text/plain
In order to test if everything is OK, check if you can get your predictands
curl -i -H "token: your_token" http://meteo.unican.es/dp/rest/predictands
Success
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Date: Mon, 24 Mar 2014 14:48:05 GMT {"responseCode":"success","message":"List of predictands","values":["NorthAtlantic1_TX","WestPrecipCanary","TnNorthCarolina","TxMaxTempUSA","PrecipGSN","TxUSAPacific","Namibia"]}