Unable to connect via Connect-SnipeitPS
MrCarter2959 opened this issue · 7 comments
Context
After updating to the current version of the module, unable to log into the API
Your Environment
- SnipitPS Module version used: 1.10.213
- Operating System and PowerShell version: Windows 10, PS 5.1.19041.1320
- Snipe It version: v5.3.5 - build 6558
SnipeIT is setup to use SAML Authentication, but otherwise everything is configured according to SnipeIT Documentation Best Practices
Current Behavior
Unable to log into SnipeIT API using Connect-SnipeitPS
Connect-SnipeitPS -url $url -apiKey $secret -Verbose
VERBOSE: Testing connection to https://dns_name.
VERBOSE: [ConvertTo-GetParameter] Making HTTP get parameter string out of a hashtable
VERBOSE: [Invoke-SnipeitMethod] Invoking method Get to URI
VERBOSE: GET https://dns_name/api/v1/statuslabels?limit=1 with 0-byte payload
VERBOSE: [Invoke-SnipeitMethod] Failed to get an answer from the server
VERBOSE: [Invoke-SnipeitMethod] Status code: Unauthorized
VERBOSE: System.Net.HttpWebResponse
VERBOSE: Status:
VERBOSE: Messages:
VERBOSE: [Invoke-SnipeitMethod] Function ended
VERBOSE: Connection to https://dns_name tested succesfully.
There's line "Status code: Unauthorized" , I would start by rechecking api-key stored in $secret variable.
And yes, Connect-SnipeitPS should return error in cases like this. I'll write a fix for that.
There's line "Status code: Unauthorized" , I would start by rechecking api-key stored in $secret variable.
I've re-generated my API Token a couple of times and still meet the error. Has it changed how the API Token should be generated? I was using the instructions from here - https://snipe-it.readme.io/reference/generating-api-tokens
I only know that way to genarate api keys. In what group user account that generated api key is? (look at your.site/admin/groups)
Connection check is making request to site/api/v1/statuslabels, maybe that could fail if user does not belong to group with access to view status labels?
To test if this is permission issue, you can try try to run following commands:
Get-SnipeitStatus -url $url -apiKey $secret -verbose
and then
Get-SnipeitAsset -url $url -apiKey $secret -verbose
if just first command fails , your api user does not have right permissions. If both fails your api key is wrong or corrupted.
No activity, closing this
If anyone comes accross this same issue, it was a issue with my Apache Site Config. In my i had AllowOverride None, I changed it to AllowOverride All and did a restart of Apache2 and the issue was fixed