MissingTokenError when using us-west

I’m using the Batch API with the sentinelhub Python library.

When I set sh_base_url to us-west:

config = SHConfig()
config.sh_client_id = ...
config.sh_client_secret = ...
config.sh_base_url = "https://services-uswest2.sentinel-hub.com"
config.save()

Then any subsequent requests fail:

SentinelHubBatch.get_tiling_grid(2, config=config)

With:

MissingTokenError: (missing_token) Missing access token parameter

This doesn’t happen if I set sh_base_url to "https://services.sentinel-hub.com".

Is this some account auth settings that need to be changed or am I doing something wrong?

(The reason for using us-west is that we need MODIS, which seems to be only on us-west.)

Similar issue if I try to get a token using oauth directly:

...

client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client)

token = oauth.fetch_token(
    token_url="https://services-uswest2.sentinel-hub.com/oauth/token",
    client_id=client_id,
    client_secret=client_secret,
)
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.

If I use the regular EU endpoint and an EU S3 bucket (remember this is MODIS which is only on us-west), then the jobs are created, but analysis fails.

 'status': 'FAILED',
 'error': 'Error occurred during analysis of the request.'

If I use a us-west bucket, then creating the jobs obviously fails with "bucket in wrong AWS region".

Hi @chris1 ,

Your approach was correct: you have actually discovered a buried bug in the sentinelhub-py code, so thank you for posting in the forum! The team in charge of the Python package is working on a fix, and we will update this thread when it is rolled out.

In the meantime, if you want to run Batch API in Python, I would suggest you use the requests library. I have written an example of how you would run a batch request with MODIS data, using the us-west endpoint. From there on, you can follow the example snippets from the documentation. If you follow this route, remember to use a bucket located in US-West (Oregon) and to change the endpoint in the example commands.

Sorry for the inconvenience!

Thanks maxim, confirming that your code works and have managed to reorganise my little loop to play nicely with this!

1 Like

Hi @maxim.lamare ! Any news on this? I also get this MissingTokenError trying to download Sentinel-3 OLCI data with earthspy (setting config.sh_base_url to "https://creodias.sentinel-hub.com" in a catalog.search() then using the resulting search iterator in a process API request)

Thank you a lot in advance for your help! :slight_smile: