Skip to content

Commit e227bdf

Browse files
committed
Add support for API auth with access token
1 parent 933b910 commit e227bdf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bioblend/galaxyclient.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(
3434
self,
3535
url: str,
3636
key: Optional[str] = None,
37+
token: Optional[str] = None,
3738
email: Optional[str] = None,
3839
password: Optional[str] = None,
3940
verify: bool = True,
@@ -72,13 +73,18 @@ def __init__(
7273
# password and grab user's key before first request.
7374
if key:
7475
self._key: Optional[str] = key
76+
elif token:
77+
self.token: Optional[str] = token
7578
else:
7679
self._key = None
7780
self.email = email
7881
self.password = password
7982
self.json_headers: dict = {"Content-Type": "application/json"}
8083
# json_headers needs to be set before key can be defined, otherwise authentication with email/password causes an error
81-
self.json_headers["x-api-key"] = self.key
84+
if token:
85+
self.json_headers["Authorization"] = f"Bearer {self.token}"
86+
else:
87+
self.json_headers["x-api-key"] = self.key
8288
# Number of attempts before giving up on a GET request.
8389
self._max_get_attempts = 1
8490
# Delay in seconds between subsequent retries.

0 commit comments

Comments
 (0)