Login to Cisco ACI using API

Abstract

This post summarizes how to login to a Cisco ACI fabric using API via curl.

Login

The login process set a cookie and give a token. Both are needed to send other API requests:

# curl -c /tmp/cookie -b /tmp/cookie -k -s -X POST -d '{"aaaUser":{"attributes":{"name":"admin","pwd":"password"}}}' -H 'Content-type: application/json' 'https://172.25.82.1/api/aaaLogin.json?gui-token-request=yes' | python -m json.tool | grep urlToken

Refresh

A refresh is used to reset the session timer:

# curl -c /tmp/cookie -b /tmp/cookie -k -s -X GET 'https://172.25.82.1/api/class/aaaUser.json?challenge=557c50785a8a6e759f39f139db86b4cafbaefe0e984305a1173c0cc4396cc474' | python -m json.tool

Default session timer is 300 seconds.

Logout

Logout ends a session but doesn’t delete the token:

# curl -c /tmp/cookie -b /tmp/cookie -k -s -X POST -d '{"aaaUser":{"attributes":{"name":"admin"}}}' -H 'Content-type: application/json' 'https://172.25.82.1/api/aaaLogout.json?challenge=557c50785a8a6e759f39f139db86b4cafbaefe0e984305a1173c0cc4396cc474' | python -m json.tool

References

Posted on 19 Mar 2018 by Andrea.
  • Gmail icon
  • Twitter icon
  • Facebook icon
  • LinkedIN icon
  • Google+ icon