GET /user does not return the current user when using an api token #2644

Closed
opened 2024-08-24 15:29:44 +00:00 by ce72 · 3 comments
Contributor

Description

  1. Create an API token with all permissions on try.vikunja.io
  2. curl -X GET -H "Authorization: Bearer tk_1183642d1f350dc258c601f253aba243f20670bb" "https://try.vikunja.io/api/v1/user"
    Expected result: User details and settings for the owner of the token
    Actual result: HTTP Status 401 {"message":"missing, malformed, expired or otherwise invalid token provided"}

The request is okay, as can be seen with curl -X GET -H "Authorization: Bearer tk_1183642d1f350dc258c601f253aba243f20670bb" "https://try.vikunja.io/api/v1/tasks/all".
Also, the endpoint is correct, as can be seen if you paste the token from your browser's local storage into the first statement.

Additionally: The swagger documentation of the GET user endpoint https://try.vikunja.io/api/v1/docs#tag/user might be outdated. The return type seems to be UserWihSettings.

Vikunja Version

v0.24.1-47-9ed33f5c08

Browser and version

chrome, curl

Can you reproduce the bug on the Vikunja demo site?

Yes

Screenshots

No response

### Description 1. Create an API token with all permissions on try.vikunja.io 2. `curl -X GET -H "Authorization: Bearer tk_1183642d1f350dc258c601f253aba243f20670bb" "https://try.vikunja.io/api/v1/user"` Expected result: User details and settings for the owner of the token Actual result: HTTP Status 401 `{"message":"missing, malformed, expired or otherwise invalid token provided"}` The request is okay, as can be seen with `curl -X GET -H "Authorization: Bearer tk_1183642d1f350dc258c601f253aba243f20670bb" "https://try.vikunja.io/api/v1/tasks/all"`. Also, the endpoint is correct, as can be seen if you paste the token from your browser's local storage into the first statement. Additionally: The swagger documentation of the GET user endpoint https://try.vikunja.io/api/v1/docs#tag/user might be outdated. The return type seems to be UserWihSettings. ### Vikunja Version v0.24.1-47-9ed33f5c08 ### Browser and version chrome, curl ### Can you reproduce the bug on the Vikunja demo site? Yes ### Screenshots _No response_
ce72 added the
kind/bug
label 2024-08-24 15:29:44 +00:00
Author
Contributor
Blocks https://gitlab.com/ce72/vja/-/issues/7
Owner

I've changed the api docs in 2dd21d96547d8c9b2386000766ab3697866e86a7.

I'm unsure about giving every token access to /user, but I can see the point. Maybe as a middle ground, we could add a permission to the endpoint? That would make that endpoint available for selection, when creating a token.

I've changed the api docs in 2dd21d96547d8c9b2386000766ab3697866e86a7. I'm unsure about giving every token access to /user, but I can see the point. Maybe as a middle ground, we could add a permission to the endpoint? That would make that endpoint available for selection, when creating a token.
Owner

Added in 3e9c41cfc6. You can now add the user scope to an api token. Tokens with that scope can then access the /user endpoint and retrieve the user who created the token.

Added in https://kolaente.dev/vikunja/vikunja/commit/3e9c41cfc6ae28edcd0589359015b9aa418822f3. You can now add the `user` scope to an api token. Tokens with that scope can then access the `/user` endpoint and retrieve the user who created the token.
This repo is archived. You cannot comment on issues.
2 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vikunja/vikunja#2644
No description provided.