User accounts and authentication
This page describes how to create a user account and log in to use the API.
Overview
We support ENA Webin authentication for access and authorization:
EMBL-EBI’s European Nucleotide Archive (ENA) WEBIN authentication service
Authentication API documentation
Please refer to ENA Webin authentication API documentation
Webin authentication is token based—this means that once you have an account, you can log in with your username and password to receive a token.
This is a piece of text that contains all the information we need to know who you are and what data you are allowed to access. You present this token to the API every time you make a request.
The Webin authentication token lasts for 3 hours unless a long validity token is requested using the time-to-live (ttl) parameter,
so if you have a long-running process, you may find the token expiring before the process completes.
Please note that the following guide is for authentication against our production system. If you are testing in our development server, please replace the following URLs.
Webin Authentication
Original |
Replace with |
Creating your account
You can create an account through the ENA WEBIN AUTHENTICATION SWAGGER UI.
How to get a token
You can obtain a WEBIN AUTHENTICATION token by executing the following curl command.
Example request
TOKEN=$(curl -X POST "https://www.ebi.ac.uk/ena/submit/webin/auth/token" \
-H "accept: */*" \
-H "Content-Type: application/json" \
-d "{\"authRealms\":[\"ENA\"],\"password\":\"your_webin_password\",\"username\":\"your_webin_username\"}")
The response will contain the WEBIN AUTHENTICATION token.
Example response
eyJhbGciOi...your.jwt.token...FC2Rdig
|
Note
|
The token is valid for 3 hours. |
How to use the obtained token
You need to add this token as an Authorization header to all of your API requests.
The format is Authorization: Bearer $TOKEN.
Example request
curl -i -X POST \
-H "Accept: application/hal+json" \
-H "Content-Type: application/hal+json" \
-H "Authorization: Bearer $TOKEN" \
https://www.ebi.ac.uk/biosamples/samples \
-d "{ /* sample content */ }"
Don’t copy and paste your token
You don’t need to manually copy and paste the token. Instead, write it to an environment variable:
TOKEN=$(curl -X POST "https://www.ebi.ac.uk/ena/submit/webin/auth/token" \
-H "accept: */*" \
-H "Content-Type: application/json" \
-d "{\"authRealms\":[\"ENA\"],\"password\":\"your_webin_password\",\"username\":\"your_webin_username\"}")
You can then use the environment variable like this:
curl -i -X POST \
-H "Accept: application/hal+json" \
-H "Content-Type: application/hal+json" \
-H "Authorization: Bearer $TOKEN" \
https://www.ebi.ac.uk/biosamples/samples \
-d "{ /* sample content */ }"
Be careful with your token; anyone with it can act as if they are you.