Basic HTTP Authentication

What I’m trying to do:
Trying to access the Garmin inreach inbound API, which requires basic HTTP authentication.

What I’ve tried and what’s not working:
I’ve successfully done this in stock python using the following code, but can’t figure out how to successfully translate this into an anvil.http request and could do with some help. TIA!

Code Sample:

# this is a formatted code snippet.
# paste your code between ``` 

auth = requests.auth.HTTPBasicAuth('username', 'password')
response = requests.post(url="https://eur-origin.explore.garmin.com:443/ipcinbound/V1/Tracking.svc/Tracking", 
                            json = payload_dict, 
                            auth=auth)
r = response.status_code
if r ==200:
  return True
else:
  return r

Clone link:
share a copy of your app

Per the API in the docs ( Anvil Docs | anvil.http ) you can pass in headers to the Anvil HTTP requests call. Pass in an Authorization header, formatted to include both the user id and password, as per: IBM Documentation

That’s untested, so if it doesn’t work as is, play with the Authorization header.

Another alternative is to make the request from an Anvil server module, where you have the standard Python requests library available.

Tried it in server and it’s currently timing out. Work in progress!