Every API call needs an access token. You create it from a long-lived refresh token. See also the NetApp Console automation documentation.
export CONSOLE_API=https://cloudmanager.cloud.netapp.com- Open the Refresh Token Generator and generate a token for your Console account.
- Store it in
REFRESH_TOKEN. Treat the refresh token like a password.
export REFRESH_TOKEN="<refresh_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.
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_tokenAfter 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}"