seanpedrickcase commited on
Commit
eafaaed
·
1 Parent(s): 9013fdc

Allowed for Cognito login in situations where client secret is not provided

Browse files
Files changed (1) hide show
  1. 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
- # response = client.initiate_auth(
50
- # AuthFlow='USER_PASSWORD_AUTH',
51
- # AuthParameters={
52
- # 'USERNAME': username,
53
- # 'PASSWORD': password,
54
- # },
55
- # ClientId=client_id
56
- # )
 
57
 
58
- response = client.initiate_auth(
59
- AuthFlow='USER_PASSWORD_AUTH',
60
- AuthParameters={
61
- 'USERNAME': username,
62
- 'PASSWORD': password,
63
- 'SECRET_HASH': secret_hash
64
- },
65
- ClientId=client_id
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'):