vaphes / pocketbase

PocketBase client SDK for python
https://pypi.org/project/pocketbase/
MIT License
359 stars 41 forks source link

Wrong authentication headers #19

Closed paulocoutinhox closed 1 year ago

paulocoutinhox commented 1 year ago

Hi,

After debug a lot your code, i found my problem.

You need use only the token in authentication header.

Need change inside file client.py from:

auth_type = "Admin"
if hasattr(self.auth_store.model, "verified"):
    auth_type = "User"
config["headers"] = config.get("headers", {})
config["headers"].update(
    {"Authorization": f"{auth_type} {self.auth_store.token}"}
)

to:

config["headers"] = config.get("headers", {})
config["headers"].update(
    {"Authorization": f"{self.auth_store.token}"}
)

or

config["headers"] = config.get("headers", {})
config["headers"].update(
    {"Authorization": f"Bearer {self.auth_store.token}"}
)

This is documented in: https://pocketbase.io/docs/authentication/#authenticate-as-admin

Can you make a fast hotfix?

Thanks.

paulocoutinhox commented 1 year ago

I made a PR: https://github.com/vaphes/pocketbase/pull/20

kamyabnazari commented 1 year ago

Hi as I have mentioned in #20, this can be closed now, because solution has been merged already.