Commit 234a41fe authored by Knut Behrends's avatar Knut Behrends
Browse files

USAGE.md - how to login from command line

parent 9d39d364
......@@ -23,19 +23,30 @@ Q: How do I get an Access Token?
A: Using a Browser, Login via the web interface once.
Then, after successful login, use the Browser's developer tools (F11 or CTRL+Shift+I) to find the value of the `Authorization` HTTP-header for your login request.
This will look like this:
Then, after successful login, use the Browser's developer tools (F11 or CTRL+Shift+I) to find the value of the `Authorization` HTTP-header for your login request.
This header will look like this:
`Authorization: "Bearer eQv809NUzP4447eD3Ws4dBwCOFvf0E8I`
Copy the value after `Bearer`.
Here you would need `eQv809NUzP4447eD3Ws4dBwCOFvf0E8I`.
Enter this into line 1 of `src/config.js`, or export it as a shell environment variable `token`:
`export token=eQv809NUzP4447eD3Ws4dBwCOFvf0E8I`.
### Alternative: Login from command-line
You can also isue a HTTP POST request, e.g. with *curl* and *jq*:
`curl -F 'username=...' -F 'password=...' -sL https://data.icdp-online.org/mdis/internal/api/v1/auth/login | jq -r .token`
See also "Configuration" section at [bottom of page](#configuration)
Result:
`6WrBVjnXUIwJRYzaxesCQGdptG5q-FFu`
### Include the Token in your scripts
Enter this into line 1 of `src/config.js`, or export it as a shell environment variable `token`:
`export token=eQv809NUzP4447eD3Ws4dBwCOFvf0E8I`. (You must use a different value for your token.)
TODO: enable login from command-line
See also "Configuration" section at [bottom of page](#configuration).
### Node v14+ required
......@@ -45,7 +56,7 @@ Written in Javascript for the Node Platform v14+. You *must* use node v14+, beca
First, look at the `bin/` subdirectory to execute Shell scripts, or enter the `src/` subdirectory to execute Node scripts.
For regular usage, call the scripts from the parent directory.
For regular usage, set the working directory to the parent directory of `bin/` and `src/`, and call the scripts from there.
-----
......@@ -413,7 +424,7 @@ node list-values.js -n CITIES -e
To use the scripts you must get a [Bearer token](https://data.icdp-online.org/mdis-docs/guide/rest-api/#security) for the REST API first. Add it either as an environment variable (`export token=thiSisWHatAtOKENlooKSLikE`), or insert it at the top of the `src/config` file.
Example.
#### Example
Response for a user that has an expired token, and not enough privileges to add new data.
......
let token = process.env.token || "vlR4K7hb6YDoQGddGSuVoWe0N2g1VFr8"
let token = process.env.token || "jJsJJOQovOiybDTraBrLw4Gg6Axyzcb3"
let config = {
token: token,
endpoint: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment