Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthAPIError #85

Open
3 tasks
kuchaale opened this issue Feb 24, 2025 · 2 comments
Open
3 tasks

AuthAPIError #85

kuchaale opened this issue Feb 24, 2025 · 2 comments

Comments

@kuchaale
Copy link

  • See the output below:
---------------------------------------------------------------------------
AuthAPIError                              Traceback (most recent call last)
Cell In[11], line 1
----> 1 dsd = cat.to_dataset_dict(
      2     globus_endpoint=COLLECTION_UUID, # <-- your data here
      3     globus_path=globus_path, # <-- additional path
      4 )

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/intake_esgf/catalog.py:671](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/intake_esgf/catalog.py#line=670), in ESGFCatalog.to_dataset_dict(self, minimal_keys, ignore_facets, separator, num_threads, quiet, add_measures, globus_endpoint, globus_path, operators)
    668 infos = self._get_file_info(dataset_ids, quiet, separator, search_facets)
    670 # Move the data if we need to
--> 671 results = self._move_data(infos, num_threads, globus_endpoint, globus_path)
    673 # Load into xarray objects
    674 ds = {}

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/intake_esgf/catalog.py:510](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/intake_esgf/catalog.py#line=509), in ESGFCatalog._move_data(self, infos, num_threads, globus_endpoint, globus_path)
    508 if globus_endpoint is not None:
    509     logger.info("partition info counts")
--> 510     infos_https, infos_globus = self._partition_infos(infos)
    511     globus_path = Path(globus_path).expanduser()
    512     logger.info(f"└─ {len(infos_https)}: https")

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/intake_esgf/catalog.py:447](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/intake_esgf/catalog.py#line=446), in ESGFCatalog._partition_infos(self, infos)
    445 for uuid in globus_endpoints:
    446     try:
--> 447         ep = client.get_endpoint(uuid)
    448         if ep["acl_available"]:
    449             infos_globus[uuid] = []

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/services/transfer/client.py:227](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/services/transfer/client.py#line=226), in TransferClient.get_endpoint(self, endpoint_id, query_params)
    204 """
    205 :param endpoint_id: ID of endpoint to lookup
    206 :param query_params: Any additional parameters will be passed through
   (...)
    224             :ref: transfer/endpoints_and_collections/#get_endpoint_or_collection_by_id
    225 """  # noqa: E501
    226 log.info(f"TransferClient.get_endpoint({endpoint_id})")
--> 227 return self.get(f"endpoint/{endpoint_id}", query_params=query_params)

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/client.py:254](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/client.py#line=253), in BaseClient.get(self, path, query_params, headers, automatic_authorization)
    248 """
    249 Make a GET request to the specified path.
    250 
    251 See :py:meth:`~.BaseClient.request` for details on the various parameters.
    252 """
    253 log.debug(f"GET to {path} with query_params {query_params}")
--> 254 return self.request(
    255     "GET",
    256     path,
    257     query_params=query_params,
    258     headers=headers,
    259     automatic_authorization=automatic_authorization,
    260 )

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/client.py:424](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/client.py#line=423), in BaseClient.request(self, method, path, query_params, data, headers, encoding, allow_redirects, stream, automatic_authorization)
    422 # make the request
    423 log.debug("request will hit URL: %s", url)
--> 424 r = self.transport.request(
    425     method=method,
    426     url=url,
    427     data=data,
    428     query_params=query_params,
    429     headers=rheaders,
    430     encoding=encoding,
    431     authorizer=authorizer,
    432     allow_redirects=allow_redirects,
    433     stream=stream,
    434 )
    435 log.debug("request made to URL: %s", r.url)
    437 if 200 <= r.status_code < 400:

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/transport/requests.py:315](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/transport/requests.py#line=314), in RequestsTransport.request(self, method, url, query_params, data, headers, encoding, authorizer, allow_redirects, stream)
    311 log.debug("transport request retry cycle. attempt=%d", attempt)
    312 # add Authorization header, or (if it's a NullAuthorizer) possibly
    313 # explicitly remove the Authorization header
    314 # done fresh for each request, to handle potential for refreshed credentials
--> 315 self._set_authz_header(authorizer, req)
    317 ctx = RetryContext(attempt, authorizer=authorizer)
    318 try:

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/transport/requests.py:251](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/transport/requests.py#line=250), in RequestsTransport._set_authz_header(self, authorizer, req)
    247 def _set_authz_header(
    248     self, authorizer: GlobusAuthorizer | None, req: requests.Request
    249 ) -> None:
    250     if authorizer:
--> 251         authz_header = authorizer.get_authorization_header()
    252         if authz_header:
    253             req.headers["Authorization"] = authz_header

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/authorizers/renewing.py:171](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/authorizers/renewing.py#line=170), in RenewingAuthorizer.get_authorization_header(self)
    167 def get_authorization_header(self) -> str:
    168     """
    169     Check to see if a new token is needed and return "Bearer <access_token>"
    170     """
--> 171     self.ensure_valid_token()
    172     log.debug(f'bearer token has hash "{self._access_token_hash}"')
    173     return f"Bearer {self.access_token}"

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/authorizers/renewing.py:165](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/authorizers/renewing.py#line=164), in RenewingAuthorizer.ensure_valid_token(self)
    162         log.debug("RenewingAuthorizer has a token, but it is expired")
    164 log.debug("RenewingAuthorizer fetching new Access Token")
--> 165 self._get_new_access_token()

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/authorizers/renewing.py:125](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/authorizers/renewing.py#line=124), in RenewingAuthorizer._get_new_access_token(self)
    119 """
    120 Given token data from _get_token_response and _extract_token_data,
    121 set the access token and expiration time, calculate the new token
    122 hash, and call on_refresh
    123 """
    124 # get the first (and only) token
--> 125 res = self._get_token_response()
    126 token_data = self._extract_token_data(res)
    128 self.expires_at = token_data["expires_at_seconds"]

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/authorizers/refresh_token.py:88](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/authorizers/refresh_token.py#line=87), in RefreshTokenAuthorizer._get_token_response(self)
     84 def _get_token_response(self) -> globus_sdk.OAuthRefreshTokenResponse:
     85     """
     86     Make a refresh token grant
     87     """
---> 88     return self.auth_client.oauth2_refresh_token(self.refresh_token)

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/services/auth/client/native_client.py:134](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/services/auth/client/native_client.py#line=133), in NativeAppAuthClient.oauth2_refresh_token(self, refresh_token, body_params)
    128 log.info("Executing token refresh without client credentials")
    129 form_data = {
    130     "refresh_token": refresh_token,
    131     "grant_type": "refresh_token",
    132     "client_id": self.client_id,
    133 }
--> 134 return self.oauth2_token(
    135     form_data, body_params=body_params, response_class=OAuthRefreshTokenResponse
    136 )

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/services/auth/client/base_login_client.py:411](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/services/auth/client/base_login_client.py#line=410), in AuthLoginClient.oauth2_token(self, form_data, body_params, response_class)
    408 if body_params:
    409     data.update(body_params)
    410 return response_class(
--> 411     self.post(
    412         "/v2/oauth2/token",
    413         data=data,
    414         encoding="form",
    415     )
    416 )

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/client.py:278](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/client.py#line=277), in BaseClient.post(self, path, query_params, data, headers, encoding, automatic_authorization)
    272 """
    273 Make a POST request to the specified path.
    274 
    275 See :py:meth:`~.BaseClient.request` for details on the various parameters.
    276 """
    277 log.debug(f"POST to {path} with query_params {query_params}")
--> 278 return self.request(
    279     "POST",
    280     path,
    281     query_params=query_params,
    282     data=data,
    283     headers=headers,
    284     encoding=encoding,
    285     automatic_authorization=automatic_authorization,
    286 )

File [~/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/client.py:442](https://notebooks.jasmin.ac.uk/home/users/.conda/envs/myjaspy/lib/python3.11/site-packages/globus_sdk/client.py#line=441), in BaseClient.request(self, method, path, query_params, data, headers, encoding, allow_redirects, stream, automatic_authorization)
    439     return GlobusHTTPResponse(r, self)
    441 log.debug(f"request completed with (error) response code: {r.status_code}")
--> 442 raise self.error_class(r)

AuthAPIError: ('POST', 'https://auth.globus.org/v2/oauth2/token', None, 400, 'Error', 'Bad Request')
  • Output of intake_esgf.__version__: 2024.7.15
  • Running the globus transfer example
@kuchaale
Copy link
Author

It works once upgraded to 2024.12.7 but once I change local_cache to globus_path, I receive the same issue.

@nocollier
Copy link
Member

nocollier commented Feb 25, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants