My SonicWall API - Bearer Token
Hi,
I successfully managed to get through most of the steps to access the MySonicWall API:
I have an access token, client_secret, tenant_serial - but I never managed to get the bearer token. I always get an 401 Unauthorized."
I followed the instruction here:
Remarks:
- I always use https://api.mysonicwall.com/api/ (and not NSM) - is that correct? (will NSM work if user does not use NSM? I tried it as well, at least I am getting a reply:
"status": { "info": [ { "code": "NOK", "level": "error", "message": "Serial (0040xxxxxxxxxx) is not registered to NSM." } ], "success": false }}
- in my account are two tenants, I tried with serials from both tenants - I always get an 401 Unauthorized. I added authorization x-api-key as well - no difference.
Tested with postman and python scripts.
Any ideas?
Thanks
Martin
Answers
Your doing better than me, i cant get a tenantserial out of mine, i get the json from the first step but there is no tenantserial in there haha
I got to the point where I "sometimes" got a bearer token (It looked to me as if you could pull it once in~ 12 hrs. Since the weekend (during my tests so far) I always get it. I would assume something has changed in backend
(one) secret was that you pull the stuff before from api.mysonicwall and the bearer token you get from NSM…
Now I am working on the last step to do the actual query and get something out of MSW - this query currently always results in a "401 unauthorized" (although I do send the bearer token)
Just give me a couple of month and by christmas I'll have it figured out… :-)
we dont have NSM so im just trying to get the api/downloads to get the latest firmware version details, but it appears that needs a token which doesnt seem possible to generate without NSM which doesnt seem right to me
have got an accesscode, but dont see how to use that for a MSW token
so i think im missing something obvious but support is taking forever to reply haha
Tenant serial number will only be populated when you have an active NSM Tenant. This instructions- https://www.sonicwall.com/support/knowledge-base/nsm-cloud-getting-token-for-msw-and-nsm-apis/231018225425867 can be used to generate NSM API token from MSW API Token. If you just want to run some MSW API query, you don't need to follow the above instructions. Just use the MSW API key to query MSW API endpoints- https://api.mysonicwall.com/mssp.html
Once you have the NSM tenantSerial and Access code, you need to run a NSM query to get the NSM Bearer Token. Here is the MSW API guide- https://www.sonicwall.com/techdocs/pdf/msw-api_guide.pdf