2

i'd like to work with the chainlink v2 api to automatically adding jobs after creating a chainlink node. using curl this works well for health

curl localhost:6688/health

but not for protected endpoints like

curl localhost:6688/v2/jobs

which returns {"errors":[{"detail":"Authentication failed"}]}

what is the auth implemented for the chainlink node? tried basic auth with curl using the node admin credentials which didn't help...

1 Answers1

2

chainlink node auth can be done via sessions.

  1. use curl with session endpoint to create cookie
  2. use the cookie to authorize endpoint access

to create a cookie in file ./cookie

export USERNAME=<chainlink admin user name>
export PASSWORD=<chainlink admin user password>
curl -c ./cookie -H 'Content-Type: application/json' -d '{"email":"'${USERNAME}'", "PASSWORD":"'${PASSWORD}'"}' localhost:6688/sessions

the cookie can now be used to access protected api endpoints

curl -b ./cookie -c ./cookie localhost:6688/v2/jobs
  • Wow! This is great information! – Patrick Collins Nov 20 '21 at 17:38
  • 1
    chainlink node account management via api: - list ether accounts: `curl -b ./cookie -c ./cookie http://localhost:6688/v2/keys/eth` - import account `curl -b ./cookie -c ./cookie -d @keystore-file.json http://localhost:6688/v2/keys/eth/import?oldpassword=` - delete account `curl -X DELETE -b ./cookie -c ./cookie http://localhost:6688/v2/keys/eth/?hard=true` – matthiaszimmermann Dec 06 '21 at 14:27
  • It doesn't seem like these URL endpoints are working for me - playing back the payload works well even though I use ``--cookie-jar`` and ``--cookie``. Did these URLs change recently? – RndmSymbl May 05 '22 at 09:46