[GH-ISSUE #593] Generated api token not valid after some hours #463

Open
opened 2026-02-25 21:31:58 +03:00 by kerem · 6 comments
Owner

Originally created by @smart-clouds-09 on GitHub (Feb 4, 2024).
Original GitHub issue: https://github.com/ciur/papermerge/issues/593

Originally assigned to: @ciur on GitHub.

The tokens, which are generated with create_token.sh are not valid anymore after a time, in my case some hours.
I have been using the token for papermerge-cli to import docs. After a time papermerge-cli throws :

/usr/local/lib/python3.10/site-packages/pydantic/_migration.py:283: UserWarning: pydantic.generics:GenericModel has been moved to pydantic.BaseModel.
warnings.warn(f'{import_path} has been moved to {new_location}.')
Unauthorized

Is a new token generated, it works for a while

Info:

  • Papermerge Version 3.0.3
Originally created by @smart-clouds-09 on GitHub (Feb 4, 2024). Original GitHub issue: https://github.com/ciur/papermerge/issues/593 Originally assigned to: @ciur on GitHub. The tokens, which are generated with create_token.sh are not valid anymore after a time, in my case some hours. I have been using the token for papermerge-cli to import docs. After a time papermerge-cli throws : /usr/local/lib/python3.10/site-packages/pydantic/_migration.py:283: UserWarning: `pydantic.generics:GenericModel` has been moved to `pydantic.BaseModel`. warnings.warn(f'`{import_path}` has been moved to `{new_location}`.') **Unauthorized** Is a new token generated, it works for a while **Info:** - Papermerge Version 3.0.3
Author
Owner

@ciur commented on GitHub (Feb 9, 2024):

Default expiration time for the token is 360 minutes (i.e. 6 hours). If you want to change that use PAPERMERGE__SECURITY__TOKEN_EXPIRE_MINUTES settings. I forgot to add that to docs. I will mark this ticket as documentation issue and update documentation accordingly.

<!-- gh-comment-id:1936213460 --> @ciur commented on GitHub (Feb 9, 2024): Default expiration time for the token is [360 minutes](https://github.com/papermerge/auth-server/blob/main/auth_server/config.py#L27) (i.e. 6 hours). If you want to change that use `PAPERMERGE__SECURITY__TOKEN_EXPIRE_MINUTES` settings. I forgot to add that to docs. I will mark this ticket as documentation issue and update documentation accordingly.
Author
Owner

@smart-clouds-09 commented on GitHub (Feb 10, 2024):

thanks, is there a value for unexpired ?

<!-- gh-comment-id:1936915013 --> @smart-clouds-09 commented on GitHub (Feb 10, 2024): thanks, is there a value for unexpired ?
Author
Owner

@ciur commented on GitHub (Feb 10, 2024):

I've updated documentation.

Is there a value for unexpired

No. Just set it to big enough value. E.g. 525600 (60x24x365) is the number of minutes in a year.

<!-- gh-comment-id:1936916019 --> @ciur commented on GitHub (Feb 10, 2024): I've updated [documentation](https://docs.papermerge.io/3.0/settings/security/#security__token_expire_minutes). > Is there a value for unexpired No. Just set it to big enough value. E.g. 525600 (60x24x365) is the number of minutes in a year.
Author
Owner

@smart-clouds-09 commented on GitHub (Feb 10, 2024):

meanwhile I have written a script, which updates the token after a few minutes. Thank for updating the docs

<!-- gh-comment-id:1936916416 --> @smart-clouds-09 commented on GitHub (Feb 10, 2024): meanwhile I have written a script, which updates the token after a few minutes. Thank for updating the docs
Author
Owner

@WolfgangFahl commented on GitHub (Aug 24, 2024):

Please reopen the issue and change the default to at least 1 year.
https://docs.papermerge.io/3.0/rest-api/token/ is also hard to find - this should be part of describing the API

<!-- gh-comment-id:2308395888 --> @WolfgangFahl commented on GitHub (Aug 24, 2024): Please reopen the issue and change the default to at least 1 year. https://docs.papermerge.io/3.0/rest-api/token/ is also hard to find - this should be part of describing the API
Author
Owner

@WolfgangFahl commented on GitHub (Aug 25, 2024):

thx i am using

# Token expiration time in minutes. Here, it's set to 2 years (1051200 minutes).
# Adjust as necessary for your security requirements.
PAPERMERGE__SECURITY__TOKEN_EXPIRE_MINUTES=1051200

as a workaround in the papermerge script at https://github.com/WolfgangFahl/scan2wiki/blob/main/scripts/papermerge

see also https://wiki.bitplan.com/index.php/Papermerge#Exploring_the_environment_variables

<!-- gh-comment-id:2308674191 --> @WolfgangFahl commented on GitHub (Aug 25, 2024): thx i am using ```bash # Token expiration time in minutes. Here, it's set to 2 years (1051200 minutes). # Adjust as necessary for your security requirements. PAPERMERGE__SECURITY__TOKEN_EXPIRE_MINUTES=1051200 ``` as a workaround in the papermerge script at https://github.com/WolfgangFahl/scan2wiki/blob/main/scripts/papermerge see also https://wiki.bitplan.com/index.php/Papermerge#Exploring_the_environment_variables
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/papermerge#463
No description provided.