Closed bhanuvrat closed 5 years ago
I had been searching all over the internet for days, and figured out right after creating the issue.. Particularly my lack of experience with org-babel syntax was the cause of delay.
Found the relevant help at http://howardism.org/Technical/Emacs/literate-programming-tutorial.html
Hoping that this will help someone else's hunting for the same answers.
#+NAME: login
#+BEGIN_SRC http :pretty json :select .auth_token :results value replace
POST http://localhost:8001/api/auth/login/
Content-Type: application/json
{
"email": "someone.important@fakemail.com",
"password": "plaintextpassword"
}
#+END_SRC
#+RESULTS: login
: eyJ0eXAiOiJKV1Q0_some_tokenish_value
*** profile fetch
#+BEGIN_SRC http :pretty :var auth_token=login
GET http://localhost:8001/api/me/
Authorization: Token ${auth_token}
#+END_SRC
#+RESULTS:
#+begin_example
{
"id": "281ae67b-d9d4-4a2e-979a-8de5de029d48",
"first_name": "someone",
"last_name": "important",
"email": "someone.important@fakemail.com",
"gender": ""
}
#+end_example
I would like to pass the authentication token received in the login request to others. How can I set the output of one block as a variable to be used by others?