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

Zenodo API communication error creating draft: FORBIDDEN #26

Open
aianta opened this issue Dec 8, 2021 · 2 comments
Open

Zenodo API communication error creating draft: FORBIDDEN #26

aianta opened this issue Dec 8, 2021 · 2 comments

Comments

@aianta
Copy link

aianta commented Dec 8, 2021

Trying to use the CLI tool, but getting the following message.

Zenodo API communication error creating draft: FORBIDDEN, {"message":"Invalid action","status":403}

I have a draft deposit created, and the generated a personal access token with all 3 possible permissions (deposit:actions, deposit:write, user:email) for the tool to use.

npx --package @iomeg/zenodo-upload zenodo_upload 5767867 activity-mining.db 0.0.2 <token>

Deposition 5767867 is a draft, with no file and the version currently set to 0.0.1.

@sverhoeven
Copy link
Member

Just ran it successfully in the Zenodo sandbox with

npx --package @iomeg/zenodo-upload zenodo_upload --sandbox  807974 CITATION.cff v0.1.1 <token with deposit:actions, deposit:write scopes>

And it created a new record at https://sandbox.zenodo.org/record/1010558 .

Could you try with a token with deposit:actions, deposit:write scopes and without user:email scope`?

Also I am soon migrating to https://github.com/zenodraft/zenodraft , which does what this library can do and more.

@jspaaks
Copy link

jspaaks commented Feb 10, 2022

Below a few notes on how you could do this with zenodraft (also uses cffconvert to generate the metadata from a CITATION.cff file). zenodraft requires an access token for the api you're using (the example uses Zenodo Sandbox, so it uses a token from a local file I had that stores the token in environment variable ZENODO_SANDBOX_ACCESS_TOKEN)

# check a few versions
$ node --version
v14.17.4
$ npm --version
6.14.14

# install the zenodraft tool from npm
$ npm install -g zenodraft

# enable bash autocomplete (optional steps)
$ TMPFILE=$(mktemp)
$ zenodraft-autocomplete > $TMPFILE
$ source $TMPFILE

# add the access token to the terminal as an environment variable
$ source ~/tokens/sandbox.zenodo.org 

# get a local copy of an arbitrary example zip file
$ wget https://sandbox.zenodo.org/record/1010558/files/sverhoeven/justatest-v0.1.0.zip

# create a new draft deposition in a new collection on zenodo sanbox
$ zenodraft --sandbox deposition create in-new-collection 
1011183

# add the zip file to the deposition 1011183
$ zenodraft --sandbox file add 1011183 justatest-v0.1.0.zip 

# get an arbitrary metadata file 
$ wget https://sandbox.zenodo.org/record/1010558/files/CITATION.cff

# zenodraft doesnt understand CITATION.cff but you can use a tool called cffconvert to 
# generate zenodo json metadata from CITATION.cff. So download cffconvert from PyPI:
$ python3 -m pip install --user cffconvert

# generate a metadata file called .zenodo.json from CITATION.cff
$ cffconvert -f zenodo > .zenodo.json

# update metadata of the draft deposition
$ zenodraft --sandbox metadata update 1011183 .zenodo.json 

# inspect the draft deposition on zenodo sandbox, if everything looks good, either click
# "Publish" on Zenodo Sandbox, or 

# publish the deposition on Zenodo Sandbox
$ zenodraft --sandbox deposition publish 1011183

The resulting record on Zenodo Sandbox is here https://sandbox.zenodo.org/record/1011183

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

3 participants