ninxsoft / Kmart

A Mac command-line tool that generates kick-ass Jamf Pro reports.
MIT License
136 stars 10 forks source link

Errors when Retrieving Jamf Pro API Endpoints #24

Closed cpeonepeloton closed 3 months ago

cpeonepeloton commented 1 year ago

I run the kmart --json /Users/Shared/Kmart/config/config.json


┌───────────────────────────────────┐
 │ RETRIEVING JAMF PRO API ENDPOINTS │
└───────────────────────────────────┘
  ├─ Unable to find 'token' and 'expires' keys in URL response
  ├─ Buildings - The operation couldn’t be completed. (KMART.KmartError error 4.)
  ├─ 
  ├─ Unable to find 'token' and 'expires' keys in URL response
  ├─ Departments - The operation couldn’t be completed. (KMART.KmartError error 4.)
  ├─ 
  ├─ Unable to find 'token' and 'expires' keys in URL response
  ├─ eBooks - The operation couldn’t be completed. (KMART.KmartError error 4.)```

I have added the credentials correctly to the config.json would this happen if SSO is in place even if we have a username/password account in jamfcloud?
ninxsoft commented 1 year ago

Hi @cpeonepeloton, KMART uses your account's standard username and password to retrieve a bearer auth token via /v1/auth/tokens, which is then used for all subsequent API calls.

KMART.KmartError error 4 refers to 'token' and 'expires' keys missing from the JSON that was returned for the auth token, indicating the username and/or password may be incorrect.

See: Classic API Authentication Changes

In my testing, I am also able to confirm that I am receiving a HTTP 401 error every time I receive the Unable to find 'token' and 'expires' keys in URL response error message, which helps confirm an invalid username / password.

I don't suspect SSO is playing a part - as we're getting a response, just not the one we want.

Am I able to confirm your username and password are base64 encoded? You can convert to base64 via the following command:

printf 'username:password' | iconv --to-code ISO-8859-1 | base64

Note: This account should be an API account, and not one that is tied to SSO in anyway 👍

ninxsoft commented 3 months ago

Closing due to inactivity. Will re-open if required 👍