API key doesn't work


#1

I’m trying to perform a basic HTTP GET request to test the Systran API. I am not using the provided client applications because I am using a programming language that does not yet have one. I am simply concatenating a query string and performing a simple HTTP GET request. However, I get a 401, indicating, I guess, that my API key is not authorized for some reason.

The request URL is:

https://api-platform.systran.net/translation/text/translate?key=XXXXX&source="en"&target="fr"&input=["This%20is%20a%20test"]

The response JSON is:

{“error”:{“message”:“This API key cannot be used, the request does not contain any referer header”,“info”:{“code”:401}}}

It is true that the request headers do not contain a Referer field, however in the SYSTRAN Platform Administration panel, I have indicating that the API should accept requests from any Referer


#2

I guess the issue of a type of API Key when you create an API Key.

try a type of API Key.


#3

Hi,

There is indeed an issue on API Key management and referrers headers. It has been fixed and is currently under testing on our staging environment.

It should be released soon in production.

best,


#4

Was this fix ever released?


#5

Yes, it was deployed in production back in March 2016, sorry we didn’t notify this here.

The issue was:

  • the default API key is of type “browser” which verifies if the requests has a valid origin via the “referer” http header
  • the default API key has an empty list of authorized origins
  • the code in production last December rejected the requests if no “referer” header was present in the request, even if no authorized origin was declared

The fix was:

  • if no authorized origin is declared for a “browser” API key, then it now means we accept all requests regardless of their origin, even if they don’t have a “referer” header.

It means that the default API key is now accepted for all usages, because [type: “browser” type + no authorized origins] is equivalent to [type: “server”]: we only verify the api key, nothing more.

Thomas