Skip to content

Commit ef32133

Browse files
committed
patch token references
1 parent f190cf6 commit ef32133

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

inventree/api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ def __init__(self, host=None, **kwargs):
8080
self.oidc_scopes = kwargs.get('oidc_scopes', os.environ.get('INVENTREE_API_OIDC_SCOPES', ['openid', 'g:read']))
8181

8282
self.use_token_auth = kwargs.get('use_token_auth', True)
83-
self.use_oidc_auth = kwargs.get('use_oidc_auth', os.environ.get('INVENTREE_API_OIDC', None))
83+
self.use_oidc_auth = kwargs.get('use_oidc_auth', os.environ.get('INVENTREE_API_OIDC', False))
84+
if self.use_oidc_auth and self.use_token_auth:
85+
self.use_token_auth = False
8486
self.verbose = kwargs.get('verbose', False)
8587

8688
self.auth = None
@@ -603,8 +605,9 @@ def downloadFile(self, url, destination, overwrite=False, params=None, proxies=d
603605
raise FileExistsError(f"Destination file '{destination}' already exists")
604606

605607
if self.token:
608+
headername = 'Token' if self.use_token_auth else 'Bearer'
606609
headers = {
607-
'AUTHORIZATION': f"Token {self.token}"
610+
'AUTHORIZATION': f"{headername} {self.token}"
608611
}
609612
auth = None
610613
else:

0 commit comments

Comments
 (0)