Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Use access token only when hostname match URL
Browse files Browse the repository at this point in the history
  • Loading branch information
nik committed Mar 20, 2024
1 parent c08cb83 commit a28f1e4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion label_studio_tools/core/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ def get_local_path(
if not os.path.exists(filepath):
logger.info('Download {url} to {filepath}'.format(url=url, filepath=filepath))
if download_resources:
headers = {'Authorization': 'Token ' + access_token} if access_token else {}
# check if url matches hostname - then uses access token to this Label Studio instance
if access_token and hostname and parsed_url.netloc == urlparse(hostname).netloc:
headers = {'Authorization': 'Token ' + access_token}
else:
headers = {}
r = requests.get(url, stream=True, headers=headers)
r.raise_for_status()
with io.open(filepath, mode='wb') as fout:
Expand Down

0 comments on commit a28f1e4

Please sign in to comment.