Skip to content

Commit 90978df

Browse files
committed
error message phrasing, add guard to token,
1 parent 44acb9c commit 90978df

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

astroquery/mast/missions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,9 @@ def _warn_no_auth(self, download_url):
771771
download_url : str
772772
The URL that the user attempted to download from, which requires authentication.
773773
"""
774-
no_auth_msg = f'You are not authorized to download from {download_url}.'
774+
no_auth_msg = f'You are not authorized to access {download_url}.'
775775
if self._authenticated:
776-
no_auth_msg += ('\nYou do not have access to download this data, or your authentication '
776+
no_auth_msg += ('\nYou do not have access to this data, or your authentication '
777777
'token may be expired. You can generate a new token at '
778778
'https://auth.mast.stsci.edu/token?suggested_name=Astroquery&'
779779
'suggested_scope=mast:exclusive_access')
@@ -1026,7 +1026,9 @@ def read_product(self, uri, *, mission=None, **kwargs):
10261026
'`pip install astroquery[all]`.', ImportWarning)
10271027

10281028
# Make an authenticated request to get the presigned S3 URL for the ASDF file
1029-
headers = {"Authorization": f"token {self._auth_obj.session.cookies['mast_token']}"}
1029+
headers = {}
1030+
if self._authenticated:
1031+
headers["Authorization"] = f"token {self._auth_obj.session.cookies['mast_token']}"
10301032
resp = requests.get(
10311033
download_url,
10321034
headers=headers,

astroquery/mast/tests/test_mast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,8 @@ def test_missions_download_no_auth(caplog):
709709
msg = str(warn_auth[0].message)
710710
assert result[0] == 'ERROR'
711711
assert 'HTTPError' in result[1]
712-
assert 'You are not authorized to download' in msg
713-
assert 'You do not have access to download this data' in msg
712+
assert 'You are not authorized to access' in msg
713+
assert 'You do not have access to this data' in msg
714714

715715

716716
def test_missions_get_dataset_kwd(caplog):

0 commit comments

Comments
 (0)