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

create_token.sh throws an error #314

Closed
htc1977 opened this issue Jan 26, 2024 · 2 comments
Closed

create_token.sh throws an error #314

htc1977 opened this issue Jan 26, 2024 · 2 comments
Assignees
Labels
3.0.2 bug Something isn't working confirmed medium

Comments

@htc1977
Copy link

htc1977 commented Jan 26, 2024

I tried to create a usertoken to mass import some documents and got this error on dockerized papermerge:3.0.2

root@dcd44b169514:/core_app# create_token.sh christian
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/auth_server_app/.venv/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/auth_server_app/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/auth_server_app/.venv/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/auth_server_app/.venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/auth_server_app/auth_server/cli/create_token.py", line 18, in cli
    user = get_user_by_username(db, username)
  File "/auth_server_app/auth_server/crud.py", line 27, in get_user_by_username
    db_user = session.scalars(stmt).one()
  File "/auth_server_app/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2420, in scalars
    return self._execute_internal(
  File "/auth_server_app/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2180, in _execute_internal
    conn = self._connection_for_bind(bind)
  File "/auth_server_app/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2047, in _connection_for_bind
    return trans._connection_for_bind(engine, execution_options)
  File "<string>", line 2, in _connection_for_bind
  File "/auth_server_app/.venv/lib/python3.10/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
  File "/auth_server_app/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1143, in _connection_for_bind
    conn = bind.connect()
AttributeError: 'Session' object has no attribute 'connect'. Did you mean: 'connection'?

any ideas, how to sail around this issue?

Thanks, Christian.

@ciur
Copy link
Member

ciur commented Jan 27, 2024

Thank you for taking your time to open this ticket!

Yes, there is an easy workaround, just use REST API to authenticate.
Example:

curl -XPOST \
        -H "Content-Type: application/json" \
        -d '{"username":"admin","password":"admin"}' \
         https://trusel.net/api/token

Here is example of response:

{"access_token":"eyJ...VCJ9.eyJzdW...Z9.FEp...nXkbM","token_type":"bearer"}

Value of "access_token" key is your REST API token.

@ciur ciur self-assigned this Jan 27, 2024
@ciur ciur added bug Something isn't working confirmed medium 3.0.2 labels Jan 27, 2024
@ciur
Copy link
Member

ciur commented Jan 29, 2024

PR with the fix in auth-server
PR to bump auth-server in core

Fix will be available in 3.0.3

@ciur ciur closed this as completed Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0.2 bug Something isn't working confirmed medium
Projects
None yet
Development

No branches or pull requests

2 participants