How to use access token generated in the web portal in API calls?
Hello,
I created an access token in the CV portal via “Security->Users->Access tokens->Add token” and the “Scope” was selected to “All”. However, when i tried to use the access token to send an API request like below, the server returned “Missing or invalid authorization header!”.
GET /v4/fileservers HTTP/1.1 Accept: application/json Authorization: Bearer QSDK <access token generated in the portal> Host: api.metallic.io Connection: keep-alive
Appreciate if anyone knows how to use the access token.
Page 1 / 1
In the Command Center you’re creating a bearer token, so the usage is
Bearer rand here the long string received during bearer token creation]
On the other hand, if you created a “regular” QSDK token ie. in /webconsole/sandbox, then the usage is
QSDK >and here the long string]
In total three headers are required:
'Authorization' = 'ohere put QSDK or Bearer token]' 'Accept' = 'application/xml' 'Content-type' = 'application/json or xml'
Hope that helps.
Thank you so much for your quick response. I tried to reperform what you said but unfortunately it didn’t work. Are you aware of what I did wrong?
This seems to be metallic related…
Anyone can help with this? Thanks.
Took a bit:)
Run /login
Take the authtoken QSDK string from the output
Use the header Authorization: Bearer QSDK string
So an example to list hypervisors after getting authtoken as “QSDK 3ad83249f8395acaa54605aef429bf1a38a0d68c8e3f34e7fa136a15a8c0832d79f73109fd10629a4c29c” from /Login you’d run: GET against https://api.metallic.io/v4/hypervisor with the below headers "Accept: application/json" "Content-type: application/json" “Authorization: Bearer QSDK 3ad83249f8395acaa54605aef429bf1a38a0d68c8e3f34e7fa136a15a8c0832d79f73109fd10629a4c29c"
Thank you for the reply. The “/Login” case did work if i provide username and password. However, i have mulit-factor authentication enabled and i couldn’t just use username and password to get the access token from “https://api.metallic.io/Login”.
This is the reason why i want to generate the access token from the portal for long-term usage.
Interestingly, I have tested the same setup to get access token from my on-premise Commvault instance and it works fine. Just the cloud version didn’t work.
The behaviour and the must of using /Login is explained :