Skip to content

Commit

Permalink
Update views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
idabblewith committed Aug 26, 2024
1 parent ade29ae commit 6421cee
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
)
from rest_framework.views import APIView
from math import ceil
import base64

import urllib3
from django.utils.text import slugify
Expand Down Expand Up @@ -703,13 +704,14 @@ def get(self, req, pk):

# Prepare API request
api_url = "https://itassets.dbca.wa.gov.au/api/v3/departmentuser"
auth = HTTPBasicAuth(
"[email protected]", settings.IT_ASSETS_ACCESS_TOKEN,
)
# headers = {
# "Authorization": f"Bearer {settings.IT_ASSETS_ACCESS_TOKEN}",
# "Accept": "application/json",
# }
user_email = "[email protected]"
user_pass = f"{user_email}:{settings.IT_ASSETS_ACCESS_TOKEN}"
encoded_credentials = base64.b64encode(user_pass.encode()).decode()
headers = {
"Authorization": f"Basic {encoded_credentials}",
"Accept": "application/json",
}

params = (
{
"pk": staff_profile.it_asset_id,
Expand All @@ -719,7 +721,8 @@ def get(self, req, pk):
"q": staff_profile.user.email,
}
)
response = requests.get(api_url, auth=auth, params=params)

response = requests.get(api_url, headers=headers, params=params)

print(params)

Expand Down

0 comments on commit 6421cee

Please sign in to comment.