File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ import requests
2
+ import os
3
+ import boto3
4
+ import json
5
+ #
6
+ # Retrieve environment variables
7
+
8
+
9
+
10
+ cog_user = os .getenv ('COG_USER' )
11
+ cog_pass = os .getenv ('COG_PASS' )
12
+ cog_client_id = os .getenv ('COG_CLIENT_ID' )
13
+
14
+ # Create a Cognito client
15
+ client = boto3 .client ('cognito-idp' )
16
+ response = client .initiate_auth (
17
+ AuthFlow = 'USER_PASSWORD_AUTH' ,
18
+ AuthParameters = {
19
+ 'USERNAME' : cog_user ,
20
+ 'PASSWORD' : cog_pass ,
21
+ },
22
+ ClientId = cog_client_id
23
+ )
24
+ token = response ['AuthenticationResult' ]['AccessToken' ]
25
+ # print("Access Token:", token) # Debug print to check the token format
26
+
27
+ headers = {'Authorization' : f'Bearer { token } ' }
28
+ # print("Headers being sent:", headers) # Debug print to check the headers
29
+
30
+ url = 'https://d3vc8w9zcq658.cloudfront.net/am-uds-dapa/collections'
31
+ response = requests .get (url , headers = headers )
32
+
33
+ # Check if the request was successful
34
+ if response .status_code == 200 :
35
+ print ("Success:" , json .dumps (response .json (), indent = 4 ))
36
+ else :
37
+ print ("Failed to fetch data:" , response .status_code , response .text )
38
+
39
+
40
+
41
+ def main ():
42
+
43
+
44
+
45
+
46
+ if __main__ == "__main__" :
47
+ main ()
You can’t perform that action at this time.
0 commit comments