Skip to content

Commit

Permalink
expire time different in oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarcesres authored Sep 18, 2023
1 parent 8548b4d commit c162f28
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions action.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
@logger.catch
def get_jamf_token(url, auth_type, username, password):
if auth_type == "auth":
token_request = requests.post(url=f"{url}/uapi/auth/tokens", auth = (username, password))
token_request = requests.post(url=f"{url}/uapi/auth/tokens", auth=(username,password))
elif auth_type =='oauth':
data = {"client_id": username,"client_secret": password, "grant_type": "client_credentials"}
token_request = requests.post(url=f"{url}/api/oauth/token", data=data)
if token_request.status_code == requests.codes.ok:
logger.success(f"got the token! it expires in: {token_request.json()['expires']}")
if auth_type == "auth":
logger.success(f"got the token! it expires in: {token_request.json()['expires']}")
elif auth_type == "oauth":
logger.success(f"got the token! it expires in: {token_request.json()['expires_in']}")
return token_request.json()['token']
elif token_request.status_code == requests.codes.not_found:
logger.error('failed to retrieve a valid token, please check the url')
Expand Down

0 comments on commit c162f28

Please sign in to comment.