Spaces:
Sleeping
Sleeping
Commit
·
eafaaed
1
Parent(s):
9013fdc
Allowed for Cognito login in situations where client secret is not provided
Browse files- tools/auth.py +19 -17
tools/auth.py
CHANGED
@@ -46,24 +46,26 @@ def authenticate_user(username:str, password:str, user_pool_id:str=user_pool_id,
|
|
46 |
|
47 |
try:
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
67 |
|
68 |
# If successful, you'll receive an AuthenticationResult in the response
|
69 |
if response.get('AuthenticationResult'):
|
|
|
46 |
|
47 |
try:
|
48 |
|
49 |
+
if client_secret == '':
|
50 |
+
response = client.initiate_auth(
|
51 |
+
AuthFlow='USER_PASSWORD_AUTH',
|
52 |
+
AuthParameters={
|
53 |
+
'USERNAME': username,
|
54 |
+
'PASSWORD': password,
|
55 |
+
},
|
56 |
+
ClientId=client_id
|
57 |
+
)
|
58 |
|
59 |
+
else:
|
60 |
+
response = client.initiate_auth(
|
61 |
+
AuthFlow='USER_PASSWORD_AUTH',
|
62 |
+
AuthParameters={
|
63 |
+
'USERNAME': username,
|
64 |
+
'PASSWORD': password,
|
65 |
+
'SECRET_HASH': secret_hash
|
66 |
+
},
|
67 |
+
ClientId=client_id
|
68 |
+
)
|
69 |
|
70 |
# If successful, you'll receive an AuthenticationResult in the response
|
71 |
if response.get('AuthenticationResult'):
|