Skip to content

Latest commit

 

History

History
executable file
·
67 lines (48 loc) · 2.33 KB

README.md

File metadata and controls

executable file
·
67 lines (48 loc) · 2.33 KB

Authentication

Every API call needs an access token. You create it from a long-lived refresh token. See also the NetApp Console automation documentation.

Set the Console API URL

export CONSOLE_API=https://cloudmanager.cloud.netapp.com

Generate a refresh token

  1. Open the Refresh Token Generator and generate a token for your Console account.
  2. Store it in REFRESH_TOKEN. Treat the refresh token like a password.
export REFRESH_TOKEN="<refresh_token>"

Exchange the refresh token for an access token

This call goes to the Auth0 authentication service, not to the Console API. The client identifier in the JSON input is the same constant value for all customers and is also listed in the official documentation.

export ACCESS_TOKEN=$(
curl -s -X POST "https://netapp-cloud-account.auth0.com/oauth/token" \
  -H "Content-Type: application/json" \
  -d "{
    \"grant_type\": \"refresh_token\",
    \"refresh_token\": \"${REFRESH_TOKEN}\",
    \"client_id\": \"Mu0V1ywgYteI6w1MbD15fKfVIUrNXGWC\"
  }" | jq -r .access_token
)

Verify that the token is set (prints the number of characters, not the token):

echo "${#ACCESS_TOKEN} characters"

The access token expires. If calls start returning 401, run the exchange again.

If the refresh token is wrong or expired, the response has no access_token and jq -r .access_token prints the text null, which only fails later as a 401. Check the length above: 4 characters means the exchange failed.

Shortcut: bnr_renew_token

env.sh.example defines a helper that does the exchange, refuses to continue when no token comes back, and prints only the token length. source env.sh runs it once; run it again whenever calls return 401:

bnr_renew_token

Environment variable summary

After completing account discovery, these variables are set. A template is in env.sh.example.

export CONSOLE_API="https://cloudmanager.cloud.netapp.com"
export REFRESH_TOKEN="<refresh_token>"
export ACCOUNT_ID="<accountPublicId>"
export WORKSPACE_ID="<workspacePublicId>"
export AGENT_ID="<agentID>"
export AGENT_IP="<agentIP>"
export AGENT_URL="https://${AGENT_IP}"