AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2025-03-10 · Documentation low

File: code-library/latest/ug/cognito-identity-provider_example_cognito-identity-provider_InitiateAuth_section.md

Summary

Added CLI examples and documentation for InitiateAuth with USER_PASSWORD_AUTH flow

Security assessment

Adds documentation about authentication flows and token handling, which are security features, but does not address specific vulnerabilities.

Diff

diff --git a/code-library/latest/ug/cognito-identity-provider_example_cognito-identity-provider_InitiateAuth_section.md
index 4d740862e..dfa8d656f 100644
--- a/code-library/latest/ug/cognito-identity-provider_example_cognito-identity-provider_InitiateAuth_section.md
+++ b/code-library/latest/ug/cognito-identity-provider_example_cognito-identity-provider_InitiateAuth_section.md
@@ -7 +7 @@ There are more AWS SDK examples available in the [AWS Doc SDK Examples](https://
-# Use `InitiateAuth` with an AWS SDK
+# Use `InitiateAuth` with an AWS SDK or CLI
@@ -68,0 +69,42 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
+CLI
+    
+
+**AWS CLI**
+    
+
+**To sign in a user**
+
+The following `initiate-auth` example signs in a user with the basic username-password flow and no additional challenges.
+    
+    
+    aws cognito-idp initiate-auth \
+        --auth-flow USER_PASSWORD_AUTH \
+        --client-id 1example23456789 \
+        --analytics-metadata AnalyticsEndpointId=d70b2ba36a8c4dc5a04a0451aEXAMPLE \
+        --auth-parameters USERNAME=testuser,PASSWORD=[Password] --user-context-data EncodedData=mycontextdata --client-metadata MyTestKey=MyTestValue
+    
+
+Output:
+    
+    
+    {
+        "AuthenticationResult": {
+            "AccessToken": "eyJra456defEXAMPLE",
+            "ExpiresIn": 3600,
+            "TokenType": "Bearer",
+            "RefreshToken": "eyJra123abcEXAMPLE",
+            "IdToken": "eyJra789ghiEXAMPLE",
+            "NewDeviceMetadata": {
+                "DeviceKey": "us-west-2_a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
+                "DeviceGroupKey": "-v7w9UcY6"
+            }
+        }
+    }
+
+For more information, see [Authentication](https://docs.aws.amazon.com/cognito/latest/developerguide/authentication.html) in the _Amazon Cognito Developer Guide_.
+
+  * For API details, see [InitiateAuth](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-idp/initiate-auth.html) in _AWS CLI Command Reference_. 
+
+
+
+