Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Added on June 30, 2022 4:53AM
Likes: 0
Replies: 5
I have created a python function API endpoint in API designer, when I run the test query, it works well.
After that, I created an API key for this API service, but when I call the public API endpoint via Postman (i found the guide here: https://doc.dataiku.com/dss/latest/apinode/first-service-apideployer.html) :
URL: mydomain.com/public/api/v1/<api service id>/<endpoint>/run
Header:
Content-Type: application/json; charset=utf-8
Authorization: Basic <my api key>
I got the response:
{
"errorType": "com.dataiku.dip.exceptions.NotAuthenticatedException",
"message": "API Key not provided (Basic xxxxxxxxxxxxxxxxxxxxxxx)",
"detailedMessage": "API Key not provided (Basic xxxxxxxxxxxxxxxxxxxxxxx)",
"detailedMessageHTML": "<span><span class=\"err-msg\">API Key not provided (Basic xxxxxxxxxxxxxxxxxxxxxxx)</span></span>",
"stackTrace": []
}
Even when i checked to "Allow public access to this service (no authentication)", i got the same error.
Anyone know the cause of this error, please help, many thanks.
Operating system used: Ubuntu 20.04
ah I found the cause, I need to create basic auth by an empty user and the password is the API key first, and I also need to restart the API service after changing the security config
Thank you for sharing your solution with the Community @manhnam91
!
Just a quick remark, although this post is almost two years old. This solution has helped me, but as of today it does not work exactly as described.
To set up authetication via API key, basic auth is indeed the way to go. But the API key needs to be entered as the user (with empty password) and not as the password.
This makes a difference because (before Base64 encoding) the tool (e.g. curl, Postman, etc.) adds a colon after the API key in the username case, whereas it is put in front of the API key in the password case.
i start seeing this error again, i am calling the REST API through python code and passing authentication as Basic <API KEY >, still seeing the same above error.
You need to make sure the Authorization: Basic <my_api_key> is base64 encoded and it contains
"api-key-value" + trailing colon ":"
An easy way to generate it if you have Postman for example is to copy the API key from DSS into the Username field in Postman, leave the password blank, and then copy the based64 variant from the headers
If we decode this we can see it included colon