T-BENZIN 94b7677108 + moon_phase.py integration module for Astronomy API: implements Pydantic models for handling API request and response
+ auth.py integration module for Astronomy API: responsible for generating an API authentication hash to be placed in request header
2024-11-19 21:53:58 +05:00

13 lines
415 B
Python

"""Authentication header encoding"""
import base64
from os import environ
app_id, app_key = environ.get('ASTRONOMY_API_APP_ID'), environ.get('ASTRONOMY_API_APP_SECRET')
userpass = f'{app_id}: {app_key}'
auth_string = base64.b64encode(userpass.encode()).decode()
auth_header = {'Authorization': f'Basic {auth_string}'}
app_id, app_key, userpass = None, None, None
if __name__ == '__main__':
print(auth_header)