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

Sandbox.Zenodo: HTTPError: 403 Client Error: FORBIDDEN for url: https://sandbox.zenodo.org/api/deposit/depositions?access_token=<access_token> #9

Closed
sgbaird opened this issue Feb 19, 2023 · 3 comments

Comments

@sgbaird
Copy link

sgbaird commented Feb 19, 2023

For sandbox.zenodo I'm getting:

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
Cell In[8], line 23
     21 key = f"matsciopt-{task_name}-benchmark-dataset"
     22 access_token = ZENODO_SANDBOX_API_KEY if sandbox else ZENODO_API_KEY
---> 23 res = ensure_zenodo(
     24     key,
     25     data=data,
     26     paths=[
     27         f"data/processed/{task_name}/sobol_probability_filter.csv",
     28         f"data/processed/{task_name}/sobol_regression.csv",
     29         f"data/processed/{task_name}/model_metadata.json",
     30         f"models/{task_name}/surrogate_models.pkl",
     31         f"models/{task_name}/cross_validation_models_0.pkl",
     32         f"models/{task_name}/cross_validation_models_1.pkl",
     33         f"models/{task_name}/cross_validation_models_2.pkl",
     34         f"models/{task_name}/cross_validation_models_3.pkl",
     35         f"models/{task_name}/cross_validation_models_4.pkl",
     36     ],
     37     sandbox=sandbox,  # remove this when you're ready to upload to real Zenodo
     38     access_token=access_token,
     39 )
     40 from pprint import pprint
     42 pprint(res.json())

File c:\Users\sterg\Miniconda3\envs\matsci-opt-benchmarks\lib\site-packages\zenodo_client\api.py:37, in ensure_zenodo(key, data, paths, **kwargs)
     35 def ensure_zenodo(key: str, data: Data, paths: Paths, **kwargs) -> requests.Response:
     36     """Create a Zenodo record if it doesn't exist, or update one that does."""
---> 37     return Zenodo(**kwargs).ensure(key=key, data=data, paths=paths)

File c:\Users\sterg\Miniconda3\envs\matsci-opt-benchmarks\lib\site-packages\zenodo_client\api.py:101, in Zenodo.ensure(self, key, data, paths)
     98     logger.info("mapped local key %s to deposition %s", key, deposition_id)
     99     return self.update(deposition_id=deposition_id, paths=paths)
--> 101 res = self.create(data=data, paths=paths)
    102 # Write the ID to the key in the local configuration
    103 # so it doesn't need to be created from scratch next time
    104 pystow.write_config(self.module, key, str(res.json()["id"]))

File c:\Users\sterg\Miniconda3\envs\matsci-opt-benchmarks\lib\site-packages\zenodo_client\api.py:126, in Zenodo.create(self, data, paths)
    117     data = {
    118         "metadata": {key: value for key, value in data.dict(exclude_none=True).items() if value},
    119     }
    121 res = requests.post(
    122     self.depositions_base,
    123     json=data,
    124     params={"access_token": self.access_token},
    125 )
--> 126 res.raise_for_status()
    128 res_json = res.json()
    129 bucket = res_json.get("links", {}).get("bucket")

File c:\Users\sterg\Miniconda3\envs\matsci-opt-benchmarks\lib\site-packages\requests\models.py:1021, in Response.raise_for_status(self)
   1016     http_error_msg = (
   1017         f"{self.status_code} Server Error: {reason} for url: {self.url}"
   1018     )
   1020 if http_error_msg:
-> 1021     raise HTTPError(http_error_msg, response=self)

HTTPError: 403 Client Error: FORBIDDEN for url: https://sandbox.zenodo.org/api/deposit/depositions?access_token=<access_token>
@cthoyt
Copy link
Owner

cthoyt commented Feb 19, 2023

This might be solved with the new release where I improved management of authorization between the production and sandbox instances

@sgbaird
Copy link
Author

sgbaird commented Mar 2, 2023

Hmm, I updated to zenodo-client-0.3.1 and am still getting this issue with sandbox=True. At least in the error message, the access token is the correct one.

It seems to work now. I refreshed my access tokens and restarted the Jupyter notebook kernel. It seems to work for both sandbox and non-sandbox now. Thanks!

@cthoyt cthoyt closed this as completed Mar 2, 2023
@cthoyt
Copy link
Owner

cthoyt commented Mar 2, 2023

@sgbaird great! feel free to open a new issue if there are any additional problems with authorization

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