Skip to content

Commit a660fa6

Browse files
committed
document preview URL token usage as API key
1 parent c91f059 commit a660fa6

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

doc/sphinx-guides/source/api/auth.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ You can reset your API Token from your account page in your Dataverse installati
6666

6767
.. _bearer-tokens:
6868

69+
Using Preview URL tokens as API Token
70+
-------------------------------------
71+
72+
If you want to access a dataset's contents shared by a preview URL (see :ref:`preview-url-to-review-unpublished-dataset`, :ref:`get-dataset-by-preview-url-token` and :ref:`create-a-preview-url-for-a-dataset`) using the API, you can use the token in the preview URL as API_TOKEN.
73+
74+
.. code-block:: bash
75+
76+
SERVER_URL=https://demo.dataverse.org
77+
PREVIEW_URL_TOKEN=a56444bc-7697-4711-8964-e0577f055fd2
78+
79+
# this gets you the file listing with the corresponding file IDs, file names and other file metadata
80+
curl "$SERVER_URL/api/datasets/privateUrlDatasetVersion/$PREVIEW_URL_TOKEN"
81+
82+
# this gets you a specific file
83+
FILE_ID=1111111
84+
FILENAME=example.txt
85+
curl -H "X-Dataverse-key:$PREVIEW_URL_TOKEN" -o "$FILENAME" "$SERVER_URL/api/access/datafile/$FILE_ID"
86+
6987
Bearer Tokens
7088
-------------
7189

doc/sphinx-guides/source/api/native-api.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3997,6 +3997,19 @@ Get Citation by Preview URL Token
39973997
39983998
curl "$SERVER_URL/api/datasets/previewUrlDatasetVersion/$PREVIEW_URL_TOKEN/citation"
39993999
4000+
Get Files Using Preview URL Token
4001+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4002+
4003+
If you want to access a dataset's contents shared by a preview URL (see :ref:`preview-url-to-review-unpublished-dataset`, :ref:`get-dataset-by-preview-url-token` and :ref:`create-a-preview-url-for-a-dataset`) using the API, you can use the token in the preview URL as API_TOKEN.
4004+
4005+
.. code-block:: bash
4006+
4007+
SERVER_URL=https://demo.dataverse.org
4008+
PREVIEW_URL_TOKEN=a56444bc-7697-4711-8964-e0577f055fd2
4009+
FILE_ID=1111111
4010+
FILENAME=example.txt
4011+
curl -H "X-Dataverse-key:$PREVIEW_URL_TOKEN" -o "$FILENAME" "$SERVER_URL/api/access/datafile/$FILE_ID"
4012+
40004013
.. _get-dataset-summary-field-names:
40014014

40024015
Get Summary Field Names

0 commit comments

Comments
 (0)