From e64f8a9932b1aa0960b77fb195fdfdab46fc284a Mon Sep 17 00:00:00 2001 From: Justin Campbell Date: Mon, 22 Mar 2021 16:33:19 -0400 Subject: [PATCH] Change cURL config filename --- docs/api/Authentication.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/api/Authentication.md b/docs/api/Authentication.md index 593e9f0..36b0c6e 100644 --- a/docs/api/Authentication.md +++ b/docs/api/Authentication.md @@ -33,14 +33,14 @@ All API calls require an access token. You can get an access token by making a P !!! warning It is **strongly** recomended to store and retrieve your login credentials in a [cURL config file](https://everything.curl.dev/cmdline/configfile) that only your user can read to avoid exposing your credentials to your shell history or the host process table. - Create a cURL config file named `wq2_login`: + Create a cURL config file named `wq2_login.config`: ```bash - nano ~/wq_login + nano ~/wq_login.config ``` Add the cURL options: ```python - # ~/wq_login + # ~/wq_login.config request = POST header = "Content-Type: application/json" data = {"username":"USERNAME","password":"PASSWORD"} @@ -49,17 +49,21 @@ All API calls require an access token. You can get an access token by making a P Restrict read permissions to your user: ```bash - chmod 700 ~/wq_login + chmod 700 ~/wq_login.config ``` Run cURL using your new config file: ```bash - curl -K ~/wq_login + curl -K ~/wq_login.config + ``` + ``` + # Expected Output: + {"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MTYxODI1MjMsIm5iZiI6MTYxNjE4MjUyMywianRpIjoiYzI2ZjY4NDctZGU2OC00ODUzLWI4ODctMTBmZDAyMDcyY2U0IiwiZXhwIjoxNjE2MTgzNDIzLCJzdWIiOiJjYW1wYjMwMyIsImZyZXNoIjpmYWxzZSwidHlwZSI6ImFjY2VzcyIsImNzcmYiOiJjYjYzZWE1My1jOWQ2LTQ5YTItYmZhMi0wY2U4N2Q3YzcxZDcifQ.T7bezsOMreMCXWR0R5w5BKI673hpOquCOnvT1XkyDjY"} ``` ??? tip "Tip for Parsing Tokens in Bash" You can parse the access token using Python like this: ```bash - curl -K ~/wq_login | \ + curl -K ~/wq_login.config | \ python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])" ``` \ No newline at end of file