Error Codes and Authentication


Even though you do not have to worry about this to much, here is some indepth information if you are curious.

Error Codes

Your channel must provide HTTP status codes in every response. The following status codes are possible:

CodeReason PhraseResult
200OKRequest successful
400Bad RequestRequest invalid, e.g. request did not pass every required parameters or a parameter was invalid.
401UnauthorizedRequest was unauthorized; the requested method requires authentication.
403ForbiddenRequest was authorized, but user is not allowed to execute this request.
404Not FoundResource of method was not found.
500Internal Server ErrorAn internal error on the server side occurred, due to extraordinary conditions.
503Service UnavailableAPI is temporarily not available (e.g. due to maintenance)

Authentication

To authenticate the junaio server at the Callback API of your server, a Hash-based Message Authentication Code (HMAC) is used. When you registered to junaio, your unique apikey was generated. All requests to the Callback API will be signed with this key and you can verify the signature with this key.
The signature is placed in the junaio Authentication Header. This header is build from attributes, which identify the request and a timestamp to avoid replay attacks:

Authorisation: junaio [RequestSignature]

 

RequestSignature=base64(sha1([apikey] + sha1([apikey] + [signatureString])))
signatureString=[http-verb] + "\n" +
[request-uri] + "\n" +
[date-header] + "\n"
apikey=Secret apikey of the Content Provider
http-verb=(GET|POST|DELETE)
request-uri=URI, which means the URL without hostname, but with the query string
(e.g. /poi/extinfo/poiid)
date-header=HTTP-Request Header with the current client time in the format of RFC
1123 (WKDAY, DD MMM YYYY HH:MM:SS TZ)
e.g. "Date: Sun, 06 May 2008 14:49:37 GMT"

Every request from the junaio server contains the additional date HTTP-Request header. If the date differs more than e.g. 15 minutes from the server time on the callback API, the callback API can refuse the request with HTTP status code 401.