Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic auth do not work with api. Missing documentation for api key. #2136

Closed
jorgen-k opened this issue Nov 3, 2024 · 4 comments
Closed
Labels
documentation Improvements or additions to documentation

Comments

@jorgen-k
Copy link

jorgen-k commented Nov 3, 2024

Version:

  • listmonk: 4.0.1
  • OS: docker (provided docker_compose)

Description of the bug and steps to reproduce:

I’ve spent several hours trying to successfully authenticate API calls with a new, standard Docker install of Listmonk. Despite following the API documentation, it was unclear how to use the API key effectively. Here’s the detailed issue:

  1. Basic Auth Expectation:
    After creating a user, I initially tried basic auth as suggested in common API setups. This returned a 403 error. There’s no mention in the documentation that basic auth is not supported or that an API key is required instead. Instead the documentation clearly gives examples that do not work.

curl -u "admin:password" http://localhost:9000/api/lists

  1. API Key Usage Confusion:
    After discovering via community discussions that an API key was possible from 4.0, I created a new user and generated an API key. However, the documentation does not provide clear guidance on how to create or use this key, leading to many trial-and-error attempts to find the correct header format, like standardized ways with Bearer or x-api-key.

  2. Working Solution After Trial and Error:
    After much experimentation, I finally got the correct format to work. However, more standard formats typically used in other APIs were unsuccessful. Not only did I have to include the specific API user name, but also the prefix "token" along with a specific syntax that was unclear from the documentation.

curl -H "Authorization: token api:MOCK_TOKEN_sdfjkhsdfhjksdfn" http://localhost:9000/api/lists

I consider this a bug, it is probably not intentional.

Suggested Improvements:

  • Clear Documentation on API Key Usage: It would be helpful if the documentation explicitly mentioned the need for an API key and provided clear working examples of the required syntax.
  • Consistent and Standard Header Format: Using a format more consistent with industry standards would improve usability.
  • Backwards compatibility: as promised in other threads it would be nice with backwards compatibility

Including these updates in the documentation would help new users avoid similar difficulties in getting started with API calls. Thank you for considering these improvements.

This issue partly for documenting my find to help others not need to struggle for hours.

@jorgen-k jorgen-k added the bug Something isn't working label Nov 3, 2024
@knadh knadh added documentation Improvements or additions to documentation and removed bug Something isn't working labels Nov 4, 2024
@knadh knadh closed this as completed in 68df637 Nov 4, 2024
@knadh
Copy link
Owner

knadh commented Nov 4, 2024

I've updated the documentation and changed curl -u username:passwordtocurl -u 'api_username:access_token'`. BasicAuth works for new API access, but instead of "password", we just have send the auto-generated token.

@jorgen-k
Copy link
Author

jorgen-k commented Nov 4, 2024

I can confirm it works also with -u api_username:access_token, apart from the token header. Thanks for the swift response!

@Virock
Copy link

Virock commented Nov 12, 2024

Can someone please direct me on how I can obtain an API username and access token? @knadh Your message says the token is auto-generated. Where do I find it?

@jorgen-k
Copy link
Author

Users -> Users. Create a new user of type API and you will see the api-key once only, so do not forget to copy it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants