-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e603bd3
commit dc9d75e
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import requests | ||
import os | ||
import boto3 | ||
import json | ||
# | ||
# Retrieve environment variables | ||
|
||
|
||
|
||
cog_user = os.getenv('COG_USER') | ||
cog_pass = os.getenv('COG_PASS') | ||
cog_client_id = os.getenv('COG_CLIENT_ID') | ||
|
||
# Create a Cognito client | ||
client = boto3.client('cognito-idp') | ||
response = client.initiate_auth( | ||
AuthFlow='USER_PASSWORD_AUTH', | ||
AuthParameters={ | ||
'USERNAME': cog_user, | ||
'PASSWORD': cog_pass, | ||
}, | ||
ClientId=cog_client_id | ||
) | ||
token = response['AuthenticationResult']['AccessToken'] | ||
# print("Access Token:", token) # Debug print to check the token format | ||
|
||
headers = {'Authorization': f'Bearer {token}'} | ||
# print("Headers being sent:", headers) # Debug print to check the headers | ||
|
||
url = 'https://d3vc8w9zcq658.cloudfront.net/am-uds-dapa/collections' | ||
response = requests.get(url, headers=headers) | ||
|
||
# Check if the request was successful | ||
if response.status_code == 200: | ||
print("Success:", json.dumps(response.json(), indent=4)) | ||
else: | ||
print("Failed to fetch data:", response.status_code, response.text) | ||
|
||
|
||
|
||
def main(): | ||
|
||
|
||
|
||
|
||
if __main__ == "__main__": | ||
main() |