You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Planetary Computer API issuing pre-expired tokens #463
Yesterday while trying to download data from the Planetary Computer using dask, I encountered an issue where the API is issuing tokens for the correct start TIME, but for the incorrect start DATE (the start date is exactly 1 -day prior). This renders the tokens expired because I can even use them.
Here is a snippet of output from a debugging I did. I instructed the code to pull a fresh url from the API for batch each time and print out the token start time. The time, for example 2025-11-19 22:40:33Z is off by exactly one day and so when the code tries to compute on that already-expired URL it fails. In summary, the API was assigning the token to Nov 19 but this code was run on Nov 20.
Data Found Fetching fresh items from API for batch... DEBUG: Token start time = 2025-11-19T22%3A40%3A33Z DEBUG: Current time = 2025-11-20 22:42:24.229570 UTC DEBUG: Token expired? True Fetching fresh items from API for batch... DEBUG: Token start time = 2025-11-19T22%3A40%3A33Z DEBUG: Current time = 2025-11-20 22:43:23.053583 UTC DEBUG: Token expired? True
I encountered an issue where the API is issuing tokens for the correct start TIME, but for the incorrect start DATE (the start date is exactly 1 -day prior). This renders the tokens expired because I can even use them.
AFAIK, SAS tokens are valid as long as the start date (st= query parameter) is in the past (or omitted) and the expiration date (se= query parameter) is in the future. From the debug message you provided it looks like your code may be checking whether the token has expired by comparing current time against the token start time. If so, it should probably be comparing against the expiration date?
The following code demonstrates that the SAS token returned by the PC data API with a start date in the past is valid:
Before signing, HTTP status code: 409 (error)
Current UTC time: 2026-01-05T18:15:03.692103+00:00
Signing assets...
SAS start time: 2026-01-04T18:15:04Z | SAS expiration time: 2026-01-06T18:15:04Z
Start precedes current: True
After signing, HTTP status code: 200 (success)
Hi, I'm having similar issues with the GBIF dataset (which is outdated by the way...).
How long is the token supposed to last ? Because having a start date in the past is fine as long as the expiry date is not barely an hour in the future which is the issue I'm encountering with the GBIF dataset
Activity
ghidalgo3 commentedon Dec 8, 2025
Can you share the link of the URL you are requesting a SAS token for?
bmcandr commentedon Jan 5, 2026
AFAIK, SAS tokens are valid as long as the start date (
st=query parameter) is in the past (or omitted) and the expiration date (se=query parameter) is in the future. From the debug message you provided it looks like your code may be checking whether the token has expired by comparing current time against the token start time. If so, it should probably be comparing against the expiration date?The following code demonstrates that the SAS token returned by the PC data API with a start date in the past is valid:
Produces the following output:
IanOndo commentedon May 25, 2026
Hi, I'm having similar issues with the GBIF dataset (which is outdated by the way...).
How long is the token supposed to last ? Because having a start date in the past is fine as long as the expiry date is not barely an hour in the future which is the issue I'm encountering with the GBIF dataset