Esempi di Amazon Cognito Identity Provider che utilizzano AWS CLI - AWS Command Line Interface

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Esempi di Amazon Cognito Identity Provider che utilizzano AWS CLI

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando Amazon Cognito Identity Provider. AWS Command Line Interface

Le operazioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni di servizio, puoi vedere le azioni nel loro contesto negli scenari correlati.

Ogni esempio include un collegamento al codice sorgente completo, in cui è possibile trovare istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Azioni

Il seguente esempio di codice mostra come utilizzareadd-custom-attributes.

AWS CLI

Per aggiungere un attributo personalizzato

Questo esempio aggiunge un attributo personalizzato CustomAttr 1 a un pool di utenti. È di tipo String e richiede un minimo di 1 carattere e un massimo di 15. ma non è obbligatorio.

Comando:

aws cognito-idp add-custom-attributes --user-pool-id us-west-2_aaaaaaaaa --custom-attributes Name="CustomAttr1",AttributeDataType="String",DeveloperOnlyAttribute=false,Required=false,StringAttributeConstraints="{MinLength=1,MaxLength=15}"

Il seguente esempio di codice mostra come utilizzareadmim-disable-user.

AWS CLI

Per disabilitare un utente

Questo esempio disabilita l'utente jane@example.com.

Comando:

aws cognito-idp admin-disable-user --user-pool-id us-west-2_aaaaaaaaa --username jane@example.com

Il seguente esempio di codice mostra come utilizzareadmim-enable-user.

AWS CLI

Per abilitare un utente

Questo esempio abilita il nome utente jane@example.com.

Comando:

aws cognito-idp admin-enable-user --user-pool-id us-west-2_aaaaaaaaa --username jane@example.com

Il seguente esempio di codice mostra come utilizzareadmin-add-user-to-group.

AWS CLI

Per aggiungere un utente a un gruppo

Questo esempio aggiunge l'utente Jane al gruppo MyGroup.

Comando:

aws cognito-idp admin-add-user-to-group --user-pool-id us-west-2_aaaaaaaaa --username Jane --group-name MyGroup

Il seguente esempio di codice mostra come utilizzareadmin-confirm-sign-up.

AWS CLI

Per confermare la registrazione dell'utente

Questo esempio conferma l'utente jane@example.com.

Comando:

aws cognito-idp admin-confirm-sign-up --user-pool-id us-west-2_aaaaaaaaa --username jane@example.com

Il seguente esempio di codice mostra come utilizzareadmin-create-user.

AWS CLI

Per creare un utente

L'admin-create-useresempio seguente crea un utente con le impostazioni specificate: indirizzo e-mail e numero di telefono.

aws cognito-idp admin-create-user \ --user-pool-id us-west-2_aaaaaaaaa \ --username diego \ --user-attributes Name=email,Value=diego@example.com Name=phone_number,Value="+15555551212" \ --message-action SUPPRESS

Output:

{ "User": { "Username": "diego", "Attributes": [ { "Name": "sub", "Value": "7325c1de-b05b-4f84-b321-9adc6e61f4a2" }, { "Name": "phone_number", "Value": "+15555551212" }, { "Name": "email", "Value": "diego@example.com" } ], "UserCreateDate": 1548099495.428, "UserLastModifiedDate": 1548099495.428, "Enabled": true, "UserStatus": "FORCE_CHANGE_PASSWORD" } }

Il seguente esempio di codice mostra come utilizzareadmin-delete-user-attributes.

AWS CLI

Per eliminare un attributo utente

Questo esempio elimina un attributo personalizzato CustomAttr 1 per l'utente diego@example.com.

Comando:

aws cognito-idp admin-delete-user-attributes --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com --user-attribute-names "custom:CustomAttr1"

Il seguente esempio di codice mostra come utilizzareadmin-delete-user.

AWS CLI

Per eliminare un utente

Questo esempio elimina un utente.

Comando:

aws cognito-idp admin-delete-user --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com

Il seguente esempio di codice mostra come utilizzareadmin-forget-device.

AWS CLI

Dimenticare un dispositivo

Questo esempio dimentica il nome utente del dispositivo jane@example.com

Comando:

aws cognito-idp admin-forget-device --user-pool-id us-west-2_aaaaaaaaa --username jane@example.com --device-key us-west-2_abcd_1234-5678

Il seguente esempio di codice mostra come utilizzareadmin-get-device.

AWS CLI

Per procurarsi un dispositivo

Questo esempio ottiene un dispositivo come nome utente jane@example.com

Comando:

aws cognito-idp admin-get-device --user-pool-id us-west-2_aaaaaaaaa --username jane@example.com --device-key us-west-2_abcd_1234-5678
  • Per API i dettagli, vedere AdminGetDevicein AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzareadmin-get-user.

AWS CLI

Per ottenere un utente

Questo esempio ottiene informazioni sul nome utente jane@example.com.

Comando:

aws cognito-idp admin-get-user --user-pool-id us-west-2_aaaaaaaaa --username jane@example.com

Output:

{ "Username": "4320de44-2322-4620-999b-5e2e1c8df013", "Enabled": true, "UserStatus": "FORCE_CHANGE_PASSWORD", "UserCreateDate": 1548108509.537, "UserAttributes": [ { "Name": "sub", "Value": "4320de44-2322-4620-999b-5e2e1c8df013" }, { "Name": "email_verified", "Value": "true" }, { "Name": "phone_number_verified", "Value": "true" }, { "Name": "phone_number", "Value": "+01115551212" }, { "Name": "email", "Value": "jane@example.com" } ], "UserLastModifiedDate": 1548108509.537 }
  • Per API i dettagli, vedere AdminGetUserin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzareadmin-initiate-auth.

AWS CLI

Per avviare l'autorizzazione

Questo esempio avvia l'autorizzazione utilizzando il AUTH flusso ADMIN _NO_ SRP _ per il nome utente jane@example.com

Il client deve avere abilitato l'accesso API per l'autenticazione basata sul server (ADMIN_NO_ _). SRP AUTH

Usa le informazioni sulla sessione nel valore restituito per chiamare -challenge. admin-respond-to-auth

Comando:

aws cognito-idp admin-initiate-auth --user-pool-id us-west-2_aaaaaaaaa --client-id 3n4b5urk1ft4fl3mg5e62d9ado --auth-flow ADMIN_NO_SRP_AUTH --auth-parameters USERNAME=jane@example.com,PASSWORD=password

Output:

{ "ChallengeName": "NEW_PASSWORD_REQUIRED", "Session": "SESSION", "ChallengeParameters": { "USER_ID_FOR_SRP": "84514837-dcbc-4af1-abff-f3c109334894", "requiredAttributes": "[]", "userAttributes": "{\"email_verified\":\"true\",\"phone_number_verified\":\"true\",\"phone_number\":\"+01xxx5550100\",\"email\":\"jane@example.com\"}" } }

Il seguente esempio di codice mostra come utilizzareadmin-list-devices.

AWS CLI

Per elencare i dispositivi per un utente

Questo esempio elenca i dispositivi per il nome utente jane@example.com.

Comando:

aws cognito-idp admin-list-devices --user-pool-id us-west-2_aaaaaaaaa --username jane@example.com

Il seguente esempio di codice mostra come utilizzareadmin-list-groups-for-user.

AWS CLI

Per elencare i gruppi per un utente

Questo esempio elenca i gruppi per il nome utente jane@example.com.

Comando:

aws cognito-idp admin-list-groups-for-user --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com

Output:

{ "Groups": [ { "Description": "Sample group", "Precedence": 1, "LastModifiedDate": 1548097827.125, "RoleArn": "arn:aws:iam::111111111111:role/SampleRole", "GroupName": "SampleGroup", "UserPoolId": "us-west-2_aaaaaaaaa", "CreationDate": 1548097827.125 } ] }

Il seguente esempio di codice mostra come utilizzareadmin-list-user-auth-events.

AWS CLI

Per elencare gli eventi di autorizzazione per un utente

Questo esempio elenca gli eventi di autorizzazione per il nome utente diego@example.com.

Comando:

aws cognito-idp admin-list-user-auth-events --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com

Il seguente esempio di codice mostra come utilizzareadmin-remove-user-from-group.

AWS CLI

Per rimuovere un utente da un gruppo

Questo esempio rimuove jane@example.com da SampleGroup.

Comando:

aws cognito-idp admin-remove-user-from-group --user-pool-id us-west-2_aaaaaaaaa --username jane@example.com --group-name SampleGroup

Il seguente esempio di codice mostra come utilizzareadmin-reset-user-password.

AWS CLI

Per reimpostare la password di un utente

Questo esempio reimposta la password per diego@example.com.

Comando:

aws cognito-idp admin-reset-user-password --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com

Il seguente esempio di codice mostra come utilizzareadmin-set-user-mfa-preference.

AWS CLI

Per impostare le MFA preferenze dell'utente

Questo esempio imposta la SMS MFA preferenza per il nome utente diego@example.com.

Comando:

aws cognito-idp admin-set-user-mfa-preference --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com --sms-mfa-settings Enabled=false,PreferredMfa=false

Il seguente esempio di codice mostra come utilizzareadmin-set-user-settings.

AWS CLI

Per configurare le impostazioni utente

Questo esempio imposta la preferenza MFA di consegna per il nome utente diego@example.com suEMAIL.

Comando:

aws cognito-idp admin-set-user-settings --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com --mfa-options DeliveryMedium=EMAIL

Il seguente esempio di codice mostra come utilizzareadmin-update-auth-event-feedback.

AWS CLI

Per fornire un feedback per un evento di autorizzazione

Questo esempio imposta il valore di feedback per un evento di autorizzazione identificato da event-id su Valid.

Comando:

aws cognito-idp admin-update-auth-event-feedback --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com --event-id c2c2cf89-c0d3-482d-aba6-99d78a5b0bfe --feedback-value Valid

Il seguente esempio di codice mostra come utilizzareadmin-update-device-status.

AWS CLI

Per aggiornare lo stato del dispositivo

Questo esempio imposta lo stato di memorizzazione del dispositivo per il dispositivo identificato da device-key su not_memored.

Comando:

aws cognito-idp admin-update-device-status --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com --device-key xxxx --device-remembered-status not_remembered

Il seguente esempio di codice mostra come utilizzareadmin-update-user-attributes.

AWS CLI

Per aggiornare gli attributi utente

Questo esempio aggiorna un attributo utente personalizzato CustomAttr 1 per l'utente diego@example.com.

Comando:

aws cognito-idp admin-update-user-attributes --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com --user-attributes Name="custom:CustomAttr1",Value="Purple"

Il seguente esempio di codice mostra come utilizzarechange-password.

AWS CLI

Per modificare una password

Questo esempio modifica una password.

Comando:

aws cognito-idp change-password --previous-password OldPassword --proposed-password NewPassword --access-token ACCESS_TOKEN
  • Per API i dettagli, vedere ChangePasswordin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzareconfirm-forgot-password.

AWS CLI

Per confermare una password dimenticata

Questo esempio conferma una password dimenticata per il nome utente diego@example.com.

Comando:

aws cognito-idp confirm-forgot-password --client-id 3n4b5urk1ft4fl3mg5e62d9ado --username=diego@example.com --password PASSWORD --confirmation-code CONF_CODE

Il seguente esempio di codice mostra come utilizzareconfirm-sign-up.

AWS CLI

Per confermare la registrazione

Questo esempio conferma la registrazione per il nome utente diego@example.com.

Comando:

aws cognito-idp confirm-sign-up --client-id 3n4b5urk1ft4fl3mg5e62d9ado --username=diego@example.com --confirmation-code CONF_CODE
  • Per API i dettagli, vedere ConfirmSignUpin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzarecreate-group.

AWS CLI

Per creare un gruppo

Questo esempio crea un gruppo con una descrizione.

Comando:

aws cognito-idp create-group --user-pool-id us-west-2_aaaaaaaaa --group-name MyNewGroup --description "New group."

Output:

{ "Group": { "GroupName": "MyNewGroup", "UserPoolId": "us-west-2_aaaaaaaaa", "Description": "New group.", "LastModifiedDate": 1548270073.795, "CreationDate": 1548270073.795 } }

Per creare un gruppo con un ruolo e una precedenza

Questo esempio crea un gruppo con una descrizione. Include anche un ruolo e una precedenza.

Comando:

aws cognito-idp create-group --user-pool-id us-west-2_aaaaaaaaa --group-name MyNewGroupWithRole --description "New group with a role." --role-arn arn:aws:iam::111111111111:role/MyNewGroupRole --precedence 2

Output:

{ "Group": { "GroupName": "MyNewGroupWithRole", "UserPoolId": "us-west-2_aaaaaaaaa", "Description": "New group with a role.", "RoleArn": "arn:aws:iam::111111111111:role/MyNewGroupRole", "Precedence": 2, "LastModifiedDate": 1548270211.761, "CreationDate": 1548270211.761 } }
  • Per API i dettagli, vedere CreateGroupin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzarecreate-user-import-job.

AWS CLI

Per creare un processo di importazione utente

Questo esempio crea un processo di importazione utente denominato MyImportJob.

Per ulteriori informazioni sull'importazione di utenti, vedere Importazione di utenti in pool di utenti da un CSV file.

Comando:

aws cognito-idp create-user-import-job --user-pool-id us-west-2_aaaaaaaaa --job-name MyImportJob --cloud-watch-logs-role-arn arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole

Output:

{ "UserImportJob": { "JobName": "MyImportJob", "JobId": "import-qQ0DCt2fRh", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548271795.471, "Status": "Created", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 } }

Carica il file.csv con curl utilizzando il file prefirmato: URL

Comando:

curl -v -T "PATH_TO_CSV_FILE" -H "x-amz-server-side-encryption:aws:kms" "PRE_SIGNED_URL"

Il seguente esempio di codice mostra come utilizzarecreate-user-pool-client.

AWS CLI

Per creare un client per un pool di utenti

Questo esempio crea un nuovo client con pool di utenti con due flussi di autorizzazione espliciti: USER _ _ AUTH e PASSWORD ADMIN SRP _NO_ _. AUTH

Comando:

aws cognito-idp create-user-pool-client --user-pool-id us-west-2_aaaaaaaaa --client-name MyNewClient --no-generate-secret --explicit-auth-flows "USER_PASSWORD_AUTH" "ADMIN_NO_SRP_AUTH"

Output:

{ "UserPoolClient": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientName": "MyNewClient", "ClientId": "6p3bs000no6a4ue1idruvd05ad", "LastModifiedDate": 1548697449.497, "CreationDate": 1548697449.497, "RefreshTokenValidity": 30, "ExplicitAuthFlows": [ "USER_PASSWORD_AUTH", "ADMIN_NO_SRP_AUTH" ], "AllowedOAuthFlowsUserPoolClient": false } }

Il seguente esempio di codice mostra come utilizzarecreate-user-pool-domain.

AWS CLI

Per creare un dominio con pool di utenti

Questo esempio crea un nuovo dominio di pool di utenti con due flussi di autorizzazione espliciti: USER _ _ AUTH e ADMIN _NO_ PASSWORD _. SRP AUTH

Comando:

aws cognito-idp create-user-pool-domain --user-pool-id us-west-2_aaaaaaaaa --domain my-new-domain

Il seguente esempio di codice mostra come utilizzarecreate-user-pool.

AWS CLI

Creazione di un pool di utenti con configurazione minima

Questo esempio crea un pool di utenti denominato MyUserPool utilizzando valori predefiniti. Non ci sono attributi obbligatori né client di applicazioni. MFAe la protezione avanzata è disattivata.

Comando:

aws cognito-idp create-user-pool --pool-name MyUserPool

Output:

{ "UserPool": { "SchemaAttributes": [ { "Name": "sub", "StringAttributeConstraints": { "MinLength": "1", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": false }, { "Name": "name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "given_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "family_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "middle_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "nickname", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "preferred_username", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "profile", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "picture", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "website", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "email", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "email_verified", "Mutable": true }, { "Name": "gender", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "birthdate", "StringAttributeConstraints": { "MinLength": "10", "MaxLength": "10" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "zoneinfo", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "locale", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "phone_number", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "phone_number_verified", "Mutable": true }, { "Name": "address", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "updated_at", "NumberAttributeConstraints": { "MinValue": "0" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "Number", "Mutable": true } ], "MfaConfiguration": "OFF", "Name": "MyUserPool", "LastModifiedDate": 1547833345.777, "AdminCreateUserConfig": { "UnusedAccountValidityDays": 7, "AllowAdminCreateUserOnly": false }, "EmailConfiguration": {}, "Policies": { "PasswordPolicy": { "RequireLowercase": true, "RequireSymbols": true, "RequireNumbers": true, "MinimumLength": 8, "RequireUppercase": true } }, "CreationDate": 1547833345.777, "EstimatedNumberOfUsers": 0, "Id": "us-west-2_aaaaaaaaa", "LambdaConfig": {} } }

Creazione di un pool di utenti con due attributi richiesti

Questo esempio crea un pool di utenti MyUserPool. Il pool è configurato per accettare l'e-mail come attributo del nome utente. Inoltre, imposta l'indirizzo e-mail di origine su un indirizzo convalidato utilizzando Amazon Simple Email Service (Amazon SES).

Comando:

aws cognito-idp create-user-pool --pool-name MyUserPool --username-attributes "email" --email-configuration=SourceArn="arn:aws:ses:us-east-1:111111111111:identity/jane@example.com",ReplyToEmailAddress="jane@example.com"

Output:

{ "UserPool": { "SchemaAttributes": [ { "Name": "sub", "StringAttributeConstraints": { "MinLength": "1", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": false }, { "Name": "name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "given_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "family_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "middle_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "nickname", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "preferred_username", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "profile", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "picture", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "website", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "email", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "email_verified", "Mutable": true }, { "Name": "gender", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "birthdate", "StringAttributeConstraints": { "MinLength": "10", "MaxLength": "10" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "zoneinfo", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "locale", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "phone_number", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "phone_number_verified", "Mutable": true }, { "Name": "address", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "updated_at", "NumberAttributeConstraints": { "MinValue": "0" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "Number", "Mutable": true } ], "MfaConfiguration": "OFF", "Name": "MyUserPool", "LastModifiedDate": 1547837788.189, "AdminCreateUserConfig": { "UnusedAccountValidityDays": 7, "AllowAdminCreateUserOnly": false }, "EmailConfiguration": { "ReplyToEmailAddress": "jane@example.com", "SourceArn": "arn:aws:ses:us-east-1:111111111111:identity/jane@example.com" }, "Policies": { "PasswordPolicy": { "RequireLowercase": true, "RequireSymbols": true, "RequireNumbers": true, "MinimumLength": 8, "RequireUppercase": true } }, "UsernameAttributes": [ "email" ], "CreationDate": 1547837788.189, "EstimatedNumberOfUsers": 0, "Id": "us-west-2_aaaaaaaaa", "LambdaConfig": {} } }
  • Per API i dettagli, vedere CreateUserPoolin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzaredelete-group.

AWS CLI

Per eliminare un gruppo

Questo esempio elimina un gruppo.

Comando:

aws cognito-idp delete-group --user-pool-id us-west-2_aaaaaaaaa --group-name MyGroupName
  • Per API i dettagli, vedere DeleteGroupin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzaredelete-identity-provider.

AWS CLI

Per eliminare un provider di identità

Questo esempio elimina un provider di identità.

Comando:

aws cognito-idp delete-identity-provider --user-pool-id us-west-2_aaaaaaaaa --provider-name Facebook

Il seguente esempio di codice mostra come utilizzaredelete-resource-server.

AWS CLI

Per eliminare un server di risorse

Questo esempio elimina un server di risorse denominato weather.example.com.

Comando:

aws cognito-idp delete-resource-server --user-pool-id us-west-2_aaaaaaaaa --identifier weather.example.com

Il seguente esempio di codice mostra come utilizzaredelete-user-attributes.

AWS CLI

Per eliminare gli attributi utente

Questo esempio elimina l'attributo utente "FAVORITE_ANIMAL».

Comando:

aws cognito-idp delete-user-attributes --access-token ACCESS_TOKEN --user-attribute-names "FAVORITE_ANIMAL"

Il seguente esempio di codice mostra come utilizzaredelete-user-pool-client.

AWS CLI

Per eliminare un client del pool di utenti

Questo esempio elimina un client del pool di utenti.

Comando:

aws cognito-idp delete-user-pool-client --user-pool-id us-west-2_aaaaaaaaa --client-id 38fjsnc484p94kpqsnet7mpld0

Il seguente esempio di codice mostra come utilizzaredelete-user-pool-domain.

AWS CLI

Per eliminare un dominio del pool di utenti

L'delete-user-pool-domainesempio seguente elimina un dominio del pool di utenti denominato my-domain

aws cognito-idp delete-user-pool-domain \ --user-pool-id us-west-2_aaaaaaaaa \ --domain my-domain

Il seguente esempio di codice mostra come utilizzaredelete-user-pool.

AWS CLI

Per eliminare un pool di utenti

Questo esempio elimina un pool di utenti utilizzando l'id del pool di utenti, us-west-2_aaaaaaaaa.

Comando:

aws cognito-idp delete-user-pool --user-pool-id us-west-2_aaaaaaaaa
  • APIPer i DeleteUserPooldettagli AWS CLI , vedere in Command Reference.

Il seguente esempio di codice mostra come utilizzaredelete-user.

AWS CLI

Per eliminare un utente

Questo esempio elimina un utente.

Comando:

aws cognito-idp delete-user --access-token ACCESS_TOKEN
  • Per API i dettagli, vedere DeleteUserin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzaredescribe-identity-provider.

AWS CLI

Per descrivere un provider di identità

Questo esempio descrive un provider di identità chiamato Facebook.

Comando:

aws cognito-idp describe-identity-provider --user-pool-id us-west-2_aaaaaaaaa --provider-name Facebook

Output:

{ "IdentityProvider": { "UserPoolId": "us-west-2_aaaaaaaaa", "ProviderName": "Facebook", "ProviderType": "Facebook", "ProviderDetails": { "attributes_url": "https://graph.facebook.com/me?fields=", "attributes_url_add_attributes": "true", "authorize_scopes": myscope", "authorize_url": "https://www.facebook.com/v2.9/dialog/oauth", "client_id": "11111", "client_secret": "11111", "token_request_method": "GET", "token_url": "https://graph.facebook.com/v2.9/oauth/access_token" }, "AttributeMapping": { "username": "id" }, "IdpIdentifiers": [], "LastModifiedDate": 1548105901.736, "CreationDate": 1548105901.736 } }

Il seguente esempio di codice mostra come utilizzaredescribe-resource-server.

AWS CLI

Per descrivere un server di risorse

Questo esempio descrive il server di risorse weather.example.com.

Comando:

aws cognito-idp describe-resource-server --user-pool-id us-west-2_aaaaaaaaa --identifier weather.example.com

Output:

{ "ResourceServer": { "UserPoolId": "us-west-2_aaaaaaaaa", "Identifier": "weather.example.com", "Name": "Weather", "Scopes": [ { "ScopeName": "weather.update", "ScopeDescription": "Update weather forecast" }, { "ScopeName": "weather.read", "ScopeDescription": "Read weather forecasts" }, { "ScopeName": "weather.delete", "ScopeDescription": "Delete a weather forecast" } ] } }

Il seguente esempio di codice mostra come utilizzaredescribe-risk-configuration.

AWS CLI

Per descrivere una configurazione di rischio

Questo esempio descrive la configurazione del rischio associata al pool us-west-2_aaaaaaaaa.

Comando:

aws cognito-idp describe-risk-configuration --user-pool-id us-west-2_aaaaaaaaa

Output:

{ "RiskConfiguration": { "UserPoolId": "us-west-2_aaaaaaaaa", "CompromisedCredentialsRiskConfiguration": { "EventFilter": [ "SIGN_IN", "SIGN_UP", "PASSWORD_CHANGE" ], "Actions": { "EventAction": "BLOCK" } }, "AccountTakeoverRiskConfiguration": { "NotifyConfiguration": { "From": "diego@example.com", "ReplyTo": "diego@example.com", "SourceArn": "arn:aws:ses:us-east-1:111111111111:identity/diego@example.com", "BlockEmail": { "Subject": "Blocked sign-in attempt", "HtmlBody": "<!DOCTYPE html>\n<html>\n<head>\n\t<title>HTML email context</title>\n\t<meta charset=\"utf-8\">\n</head>\n<body>\n<pre>We blocked an unrecognized sign-in to your account with this information:\n<ul>\n<li>Time: {login-time}</li>\n<li>Device: {device-name}</li>\n<li>Location: {city}, {country}</li>\n</ul>\nIf this sign-in was not by you, you should change your password and notify us by clicking on <a href={one-click-link-invalid}>this link</a>\nIf this sign-in was by you, you can follow <a href={one-click-link-valid}>this link</a> to let us know</pre>\n</body>\n</html>", "TextBody": "We blocked an unrecognized sign-in to your account with this information:\nTime: {login-time}\nDevice: {device-name}\nLocation: {city}, {country}\nIf this sign-in was not by you, you should change your password and notify us by clicking on {one-click-link-invalid}\nIf this sign-in was by you, you can follow {one-click-link-valid} to let us know" }, "NoActionEmail": { "Subject": "New sign-in attempt", "HtmlBody": "<!DOCTYPE html>\n<html>\n<head>\n\t<title>HTML email context</title>\n\t<meta charset=\"utf-8\">\n</head>\n<body>\n<pre>We observed an unrecognized sign-in to your account with this information:\n<ul>\n<li>Time: {login-time}</li>\n<li>Device: {device-name}</li>\n<li>Location: {city}, {country}</li>\n</ul>\nIf this sign-in was not by you, you should change your password and notify us by clicking on <a href={one-click-link-invalid}>this link</a>\nIf this sign-in was by you, you can follow <a href={one-click-link-valid}>this link</a> to let us know</pre>\n</body>\n</html>", "TextBody": "We observed an unrecognized sign-in to your account with this information:\nTime: {login-time}\nDevice: {device-name}\nLocation: {city}, {country}\nIf this sign-in was not by you, you should change your password and notify us by clicking on {one-click-link-invalid}\nIf this sign-in was by you, you can follow {one-click-link-valid} to let us know" }, "MfaEmail": { "Subject": "New sign-in attempt", "HtmlBody": "<!DOCTYPE html>\n<html>\n<head>\n\t<title>HTML email context</title>\n\t<meta charset=\"utf-8\">\n</head>\n<body>\n<pre>We required you to use multi-factor authentication for the following sign-in attempt:\n<ul>\n<li>Time: {login-time}</li>\n<li>Device: {device-name}</li>\n<li>Location: {city}, {country}</li>\n</ul>\nIf this sign-in was not by you, you should change your password and notify us by clicking on <a href={one-click-link-invalid}>this link</a>\nIf this sign-in was by you, you can follow <a href={one-click-link-valid}>this link</a> to let us know</pre>\n</body>\n</html>", "TextBody": "We required you to use multi-factor authentication for the following sign-in attempt:\nTime: {login-time}\nDevice: {device-name}\nLocation: {city}, {country}\nIf this sign-in was not by you, you should change your password and notify us by clicking on {one-click-link-invalid}\nIf this sign-in was by you, you can follow {one-click-link-valid} to let us know" } }, "Actions": { "LowAction": { "Notify": true, "EventAction": "NO_ACTION" }, "MediumAction": { "Notify": true, "EventAction": "MFA_IF_CONFIGURED" }, "HighAction": { "Notify": true, "EventAction": "MFA_IF_CONFIGURED" } } } } }

Il seguente esempio di codice mostra come utilizzaredescribe-user-import-job.

AWS CLI

Per descrivere un processo di importazione utente

Questo esempio descrive un processo di input da parte dell'utente.

Per ulteriori informazioni sull'importazione di utenti, vedere Importazione di utenti in pool di utenti da un CSV file.

Comando:

aws cognito-idp describe-user-import-job --user-pool-id us-west-2_aaaaaaaaa --job-id import-TZqNQvDRnW

Output:

{ "UserImportJob": { "JobName": "import-Test1", "JobId": "import-TZqNQvDRnW", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED URL", "CreationDate": 1548271708.512, "Status": "Created", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 } }

Il seguente esempio di codice mostra come utilizzaredescribe-user-pool-client.

AWS CLI

Per descrivere un client per un pool di utenti

Questo esempio descrive un client con pool di utenti.

Comando:

aws cognito-idp describe-user-pool-client --user-pool-id us-west-2_aaaaaaaaa --client-id 38fjsnc484p94kpqsnet7mpld0

Output:

{ "UserPoolClient": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientName": "MyApp", "ClientId": "38fjsnc484p94kpqsnet7mpld0", "ClientSecret": "CLIENT_SECRET", "LastModifiedDate": 1548108676.163, "CreationDate": 1548108676.163, "RefreshTokenValidity": 30, "ReadAttributes": [ "address", "birthdate", "custom:CustomAttr1", "custom:CustomAttr2", "email", "email_verified", "family_name", "gender", "given_name", "locale", "middle_name", "name", "nickname", "phone_number", "phone_number_verified", "picture", "preferred_username", "profile", "updated_at", "website", "zoneinfo" ], "WriteAttributes": [ "address", "birthdate", "custom:CustomAttr1", "custom:CustomAttr2", "email", "family_name", "gender", "given_name", "locale", "middle_name", "name", "nickname", "phone_number", "picture", "preferred_username", "profile", "updated_at", "website", "zoneinfo" ], "ExplicitAuthFlows": [ "ADMIN_NO_SRP_AUTH", "USER_PASSWORD_AUTH" ], "AllowedOAuthFlowsUserPoolClient": false } }

Il seguente esempio di codice mostra come utilizzaredescribe-user-pool-domain.

AWS CLI

Per descrivere un client per un pool di utenti

Questo esempio descrive un dominio del pool di utenti denominato my-domain.

Comando:

aws cognito-idp describe-user-pool-domain --domain my-domain

Output:

{ "DomainDescription": { "UserPoolId": "us-west-2_aaaaaaaaa", "AWSAccountId": "111111111111", "Domain": "my-domain", "S3Bucket": "aws-cognito-prod-pdx-assets", "CloudFrontDistribution": "aaaaaaaaaaaaa.cloudfront.net", "Version": "20190128175402", "Status": "ACTIVE", "CustomDomainConfig": {} } }

Il seguente esempio di codice mostra come utilizzaredescribe-user-pool.

AWS CLI

Per descrivere un pool di utenti

Questo esempio descrive un pool di utenti con l'id del pool di utenti us-west-2_aaaaaaaaa.

Comando:

aws cognito-idp describe-user-pool --user-pool-id us-west-2_aaaaaaaaa

Output:

{ "UserPool": { "SmsVerificationMessage": "Your verification code is {####}. ", "SchemaAttributes": [ { "Name": "sub", "StringAttributeConstraints": { "MinLength": "1", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": false }, { "Name": "name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "given_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "family_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "middle_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "nickname", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "preferred_username", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "profile", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "picture", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "website", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "email", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "email_verified", "Mutable": true }, { "Name": "gender", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "birthdate", "StringAttributeConstraints": { "MinLength": "10", "MaxLength": "10" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "zoneinfo", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "locale", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "phone_number", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "phone_number_verified", "Mutable": true }, { "Name": "address", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "updated_at", "NumberAttributeConstraints": { "MinValue": "0" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "Number", "Mutable": true } ], "EmailVerificationSubject": "Your verification code", "MfaConfiguration": "OFF", "Name": "MyUserPool", "EmailVerificationMessage": "Your verification code is {####}. ", "SmsAuthenticationMessage": "Your authentication code is {####}. ", "LastModifiedDate": 1547763720.822, "AdminCreateUserConfig": { "InviteMessageTemplate": { "EmailMessage": "Your username is {username} and temporary password is {####}. ", "EmailSubject": "Your temporary password", "SMSMessage": "Your username is {username} and temporary password is {####}. " }, "UnusedAccountValidityDays": 7, "AllowAdminCreateUserOnly": false }, "EmailConfiguration": { "ReplyToEmailAddress": "myemail@mydomain.com" "SourceArn": "arn:aws:ses:us-east-1:000000000000:identity/myemail@mydomain.com" }, "AutoVerifiedAttributes": [ "email" ], "Policies": { "PasswordPolicy": { "RequireLowercase": true, "RequireSymbols": true, "RequireNumbers": true, "MinimumLength": 8, "RequireUppercase": true } }, "UserPoolTags": {}, "UsernameAttributes": [ "email" ], "CreationDate": 1547763720.822, "EstimatedNumberOfUsers": 1, "Id": "us-west-2_aaaaaaaaa", "LambdaConfig": {} } }

Il seguente esempio di codice mostra come utilizzareforget-device.

AWS CLI

Dimenticare un dispositivo

Questo esempio dimentica un dispositivo.

Comando:

aws cognito-idp forget-device --device-key us-west-2_abcd_1234-5678
  • Per API i dettagli, vedere ForgetDevicein AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzareforgot-password.

AWS CLI

Per forzare la modifica della password

L'forgot-passwordesempio seguente invia un messaggio a jane@example.com per modificare la password.

aws cognito-idp forgot-password --client-id 38fjsnc484p94kpqsnet7mpld0 --username jane@example.com

Output:

{ "CodeDeliveryDetails": { "Destination": "j***@e***.com", "DeliveryMedium": "EMAIL", "AttributeName": "email" } }
  • Per API i dettagli, vedere ForgotPasswordin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzareget-csv-header.

AWS CLI

Per creare un'intestazione csv

Questo esempio crea un'intestazione csv.

Per ulteriori informazioni sull'importazione di utenti, vedere Importazione di utenti in pool di utenti da un file. CSV

Comando:

aws cognito-idp get-csv-header --user-pool-id us-west-2_aaaaaaaaa

Output:

{ "UserPoolId": "us-west-2_aaaaaaaaa", "CSVHeader": [ "name", "given_name", "family_name", "middle_name", "nickname", "preferred_username", "profile", "picture", "website", "email", "email_verified", "gender", "birthdate", "zoneinfo", "locale", "phone_number", "phone_number_verified", "address", "updated_at", "cognito:mfa_enabled", "cognito:username" ] }

... Importazione di utenti in pool di utenti da un CSV file: https://docs.aws.amazon.com/cognito/ cognito-user-pools-using latest/developerguide/ -import-tool.html

  • Per API i dettagli, vedere in Command Reference. GetCsvHeaderAWS CLI

Il seguente esempio di codice mostra come utilizzareget-group.

AWS CLI

Per ottenere informazioni su un gruppo

Questo esempio ottiene informazioni su un gruppo denominato MyGroup.

Comando:

aws cognito-idp get-group --user-pool-id us-west-2_aaaaaaaaa --group-name MyGroup

Output:

{ "Group": { "GroupName": "MyGroup", "UserPoolId": "us-west-2_aaaaaaaaa", "Description": "A sample group.", "LastModifiedDate": 1548270073.795, "CreationDate": 1548270073.795 } }
  • Per API i dettagli, vedere GetGroupin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzareget-signing-certificate.

AWS CLI

Per ottenere un certificato di firma

Questo esempio ottiene un certificato di firma per un pool di utenti.

Comando:

aws cognito-idp get-signing-certificate --user-pool-id us-west-2_aaaaaaaaa

Output:

{ "Certificate": "CERTIFICATE_DATA" }

Il seguente esempio di codice mostra come utilizzareget-ui-customization.

AWS CLI

Per ottenere informazioni sulla personalizzazione dell'interfaccia utente

Questo esempio ottiene informazioni sulla personalizzazione dell'interfaccia utente per un pool di utenti.

Comando:

aws cognito-idp get-ui-customization --user-pool-id us-west-2_aaaaaaaaa

Output:

{ "UICustomization": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientId": "ALL", "ImageUrl": "https://aaaaaaaaaaaaa.cloudfront.net/us-west-2_aaaaaaaaa/ALL/20190128231240/assets/images/image.jpg", "CSS": ".logo-customizable {\n\tmax-width: 60%;\n\tmax-height: 30%;\n}\n.banner-customizable {\n\tpadding: 25px 0px 25px 10px;\n\tbackground-color: lightgray;\n}\n.label-customizable {\n\tfont-weight: 300;\n}\n.textDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.idpDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.legalText-customizable {\n\tcolor: #747474;\n\tfont-size: 11px;\n}\n.submitButton-customizable {\n\tfont-size: 14px;\n\tfont-weight: bold;\n\tmargin: 20px 0px 10px 0px;\n\theight: 40px;\n\twidth: 100%;\n\tcolor: #fff;\n\tbackground-color: #337ab7;\n}\n.submitButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #286090;\n}\n.errorMessage-customizable {\n\tpadding: 5px;\n\tfont-size: 14px;\n\twidth: 100%;\n\tbackground: #F5F5F5;\n\tborder: 2px solid #D64958;\n\tcolor: #D64958;\n}\n.inputField-customizable {\n\twidth: 100%;\n\theight: 34px;\n\tcolor: #555;\n\tbackground-color: #fff;\n\tborder: 1px solid #ccc;\n}\n.inputField-customizable:focus {\n\tborder-color: #66afe9;\n\toutline: 0;\n}\n.idpButton-customizable {\n\theight: 40px;\n\twidth: 100%;\n\ttext-align: center;\n\tmargin-bottom: 15px;\n\tcolor: #fff;\n\tbackground-color: #5bc0de;\n\tborder-color: #46b8da;\n}\n.idpButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #31b0d5;\n}\n.socialButton-customizable {\n\theight: 40px;\n\ttext-align: left;\n\twidth: 100%;\n\tmargin-bottom: 15px;\n}\n.redirect-customizable {\n\ttext-align: center;\n}\n.passwordCheck-notValid-customizable {\n\tcolor: #DF3312;\n}\n.passwordCheck-valid-customizable {\n\tcolor: #19BF00;\n}\n.background-customizable {\n\tbackground-color: #faf;\n}\n", "CSSVersion": "20190128231240" } }

Il seguente esempio di codice mostra come utilizzarelist-user-import-jobs.

AWS CLI

Per elencare i lavori di importazione degli utenti

Questo esempio elenca i processi di importazione degli utenti.

Per ulteriori informazioni sull'importazione di utenti, vedere Importazione di utenti in pool di utenti da un CSV file.

Comando:

aws cognito-idp list-user-import-jobs --user-pool-id us-west-2_aaaaaaaaa --max-results 20

Output:

{ "UserImportJobs": [ { "JobName": "Test2", "JobId": "import-d0OnwGA3mV", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548272793.069, "Status": "Created", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 }, { "JobName": "Test1", "JobId": "import-qQ0DCt2fRh", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548271795.471, "Status": "Created", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 }, { "JobName": "import-Test1", "JobId": "import-TZqNQvDRnW", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548271708.512, "StartDate": 1548277247.962, "CompletionDate": 1548277248.912, "Status": "Failed", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 1, "CompletionMessage": "Too many users have failed or been skipped during the import." } ] }

Il seguente esempio di codice mostra come utilizzarelist-user-pools.

AWS CLI

Per elencare i pool di utenti

Questo esempio elenca fino a 20 pool di utenti.

Comando:

aws cognito-idp list-user-pools --max-results 20

Output:

{ "UserPools": [ { "CreationDate": 1547763720.822, "LastModifiedDate": 1547763720.822, "LambdaConfig": {}, "Id": "us-west-2_aaaaaaaaa", "Name": "MyUserPool" } ] }
  • Per API i dettagli, vedere ListUserPoolsin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzarelist-users-in-group.

AWS CLI

Per elencare gli utenti in un gruppo

Questo esempio elenca gli utenti in un gruppo MyGroup.

Comando:

aws cognito-idp list-users-in-group --user-pool-id us-west-2_aaaaaaaaa --group-name MyGroup

Output:

{ "Users": [ { "Username": "acf10624-80bb-401a-ac61-607bee2110ec", "Attributes": [ { "Name": "sub", "Value": "acf10624-80bb-401a-ac61-607bee2110ec" }, { "Name": "custom:CustomAttr1", "Value": "New Value!" }, { "Name": "email", "Value": "jane@example.com" } ], "UserCreateDate": 1548102770.284, "UserLastModifiedDate": 1548103204.893, "Enabled": true, "UserStatus": "CONFIRMED" }, { "Username": "22704aa3-fc10-479a-97eb-2af5806bd327", "Attributes": [ { "Name": "sub", "Value": "22704aa3-fc10-479a-97eb-2af5806bd327" }, { "Name": "email_verified", "Value": "true" }, { "Name": "email", "Value": "diego@example.com" } ], "UserCreateDate": 1548089817.683, "UserLastModifiedDate": 1548089817.683, "Enabled": true, "UserStatus": "FORCE_CHANGE_PASSWORD" } ] }

Il seguente esempio di codice mostra come utilizzarelist-users.

AWS CLI

Per elencare gli utenti

Questo esempio elenca fino a 20 utenti.

Comando:

aws cognito-idp list-users --user-pool-id us-west-2_aaaaaaaaa --limit 20

Output:

{ "Users": [ { "Username": "22704aa3-fc10-479a-97eb-2af5806bd327", "Enabled": true, "UserStatus": "FORCE_CHANGE_PASSWORD", "UserCreateDate": 1548089817.683, "UserLastModifiedDate": 1548089817.683, "Attributes": [ { "Name": "sub", "Value": "22704aa3-fc10-479a-97eb-2af5806bd327" }, { "Name": "email_verified", "Value": "true" }, { "Name": "email", "Value": "mary@example.com" } ] } ] }
  • Per API i dettagli, vedere ListUsersin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzareresend-confirmation-code.

AWS CLI

Per inviare nuovamente un codice di conferma

L'esempio resend-confirmation-code seguente invia un codice di conferma all'utente jane.

aws cognito-idp resend-confirmation-code \ --client-id 12a3b456c7de890f11g123hijk \ --username jane

Output:

{ "CodeDeliveryDetails": { "Destination": "j***@e***.com", "DeliveryMedium": "EMAIL", "AttributeName": "email" } }

Per ulteriori informazioni, consulta Registrazione e conferma degli account utente nella Guida per gli sviluppatori di Amazon Cognito.

Il seguente esempio di codice mostra come utilizzarerespond-to-auth-challenge.

AWS CLI

Per rispondere a una richiesta di autenticazione

Questo esempio risponde a una richiesta di autorizzazione avviata con initiate-auth. È una risposta alla REQUIRED sfida NEW PASSWORD _ _. Imposta una password per l'utente jane@example.com.

Comando:

aws cognito-idp respond-to-auth-challenge --client-id 3n4b5urk1ft4fl3mg5e62d9ado --challenge-name NEW_PASSWORD_REQUIRED --challenge-responses USERNAME=jane@example.com,NEW_PASSWORD="password" --session "SESSION_TOKEN"

Output:

{ "ChallengeParameters": {}, "AuthenticationResult": { "AccessToken": "ACCESS_TOKEN", "ExpiresIn": 3600, "TokenType": "Bearer", "RefreshToken": "REFRESH_TOKEN", "IdToken": "ID_TOKEN", "NewDeviceMetadata": { "DeviceKey": "us-west-2_fec070d2-fa88-424a-8ec8-b26d7198eb23", "DeviceGroupKey": "-wt2ha1Zd" } } }

Il seguente esempio di codice mostra come utilizzareset-risk-configuration.

AWS CLI

Per impostare la configurazione del rischio

Questo esempio imposta la configurazione del rischio per un pool di utenti. Imposta l'azione dell'evento di iscrizione su ACTION NO_.

Comando:

aws cognito-idp set-risk-configuration --user-pool-id us-west-2_aaaaaaaaa --compromised-credentials-risk-configuration EventFilter=SIGN_UP,Actions={EventAction=NO_ACTION}

Output:

{ "RiskConfiguration": { "UserPoolId": "us-west-2_aaaaaaaaa", "CompromisedCredentialsRiskConfiguration": { "EventFilter": [ "SIGN_UP" ], "Actions": { "EventAction": "NO_ACTION" } } } }

Il seguente esempio di codice mostra come utilizzareset-ui-customization.

AWS CLI

Per impostare la personalizzazione dell'interfaccia utente

Questo esempio personalizza l'CSSimpostazione per un pool di utenti.

Comando:

aws cognito-idp set-ui-customization --user-pool-id us-west-2_aaaaaaaaa --css ".logo-customizable {\n\tmax-width: 60%;\n\tmax-height: 30%;\n}\n.banner-customizable {\n\tpadding: 25px 0px 25px 10px;\n\tbackground-color: lightgray;\n}\n.label-customizable {\n\tfont-weight: 300;\n}\n.textDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.idpDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.legalText-customizable {\n\tcolor: #747474;\n\tfont-size: 11px;\n}\n.submitButton-customizable {\n\tfont-size: 14px;\n\tfont-weight: bold;\n\tmargin: 20px 0px 10px 0px;\n\theight: 40px;\n\twidth: 100%;\n\tcolor: #fff;\n\tbackground-color: #337ab7;\n}\n.submitButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #286090;\n}\n.errorMessage-customizable {\n\tpadding: 5px;\n\tfont-size: 14px;\n\twidth: 100%;\n\tbackground: #F5F5F5;\n\tborder: 2px solid #D64958;\n\tcolor: #D64958;\n}\n.inputField-customizable {\n\twidth: 100%;\n\theight: 34px;\n\tcolor: #555;\n\tbackground-color: #fff;\n\tborder: 1px solid #ccc;\n}\n.inputField-customizable:focus {\n\tborder-color: #66afe9;\n\toutline: 0;\n}\n.idpButton-customizable {\n\theight: 40px;\n\twidth: 100%;\n\ttext-align: center;\n\tmargin-bottom: 15px;\n\tcolor: #fff;\n\tbackground-color: #5bc0de;\n\tborder-color: #46b8da;\n}\n.idpButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #31b0d5;\n}\n.socialButton-customizable {\n\theight: 40px;\n\ttext-align: left;\n\twidth: 100%;\n\tmargin-bottom: 15px;\n}\n.redirect-customizable {\n\ttext-align: center;\n}\n.passwordCheck-notValid-customizable {\n\tcolor: #DF3312;\n}\n.passwordCheck-valid-customizable {\n\tcolor: #19BF00;\n}\n.background-customizable {\n\tbackground-color: #faf;\n}\n"

Output:

{ "UICustomization": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientId": "ALL", "CSS": ".logo-customizable {\n\tmax-width: 60%;\n\tmax-height: 30%;\n}\n.banner-customizable {\n\tpadding: 25px 0px 25px 10px;\n\tbackground-color: lightgray;\n}\n.label-customizable {\n\tfont-weight: 300;\n}\n.textDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.idpDescription-customizable {\n\tpadding-top: 10px;\n\tpadding-bottom: 10px;\n\tdisplay: block;\n\tfont-size: 16px;\n}\n.legalText-customizable {\n\tcolor: #747474;\n\tfont-size: 11px;\n}\n.submitButton-customizable {\n\tfont-size: 14px;\n\tfont-weight: bold;\n\tmargin: 20px 0px 10px 0px;\n\theight: 40px;\n\twidth: 100%;\n\tcolor: #fff;\n\tbackground-color: #337ab7;\n}\n.submitButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #286090;\n}\n.errorMessage-customizable {\n\tpadding: 5px;\n\tfont-size: 14px;\n\twidth: 100%;\n\tbackground: #F5F5F5;\n\tborder: 2px solid #D64958;\n\tcolor: #D64958;\n}\n.inputField-customizable {\n\twidth: 100%;\n\theight: 34px;\n\tcolor: #555;\n\tbackground-color: #fff;\n\tborder: 1px solid #ccc;\n}\n.inputField-customizable:focus {\n\tborder-color: #66afe9;\n\toutline: 0;\n}\n.idpButton-customizable {\n\theight: 40px;\n\twidth: 100%;\n\ttext-align: center;\n\tmargin-bottom: 15px;\n\tcolor: #fff;\n\tbackground-color: #5bc0de;\n\tborder-color: #46b8da;\n}\n.idpButton-customizable:hover {\n\tcolor: #fff;\n\tbackground-color: #31b0d5;\n}\n.socialButton-customizable {\n\theight: 40px;\n\ttext-align: left;\n\twidth: 100%;\n\tmargin-bottom: 15px;\n}\n.redirect-customizable {\n\ttext-align: center;\n}\n.passwordCheck-notValid-customizable {\n\tcolor: #DF3312;\n}\n.passwordCheck-valid-customizable {\n\tcolor: #19BF00;\n}\n.background-customizable {\n\tbackground-color: #faf;\n}\n", "CSSVersion": "20190129172214" } }

Il seguente esempio di codice mostra come utilizzareset-user-mfa-preference.

AWS CLI

Per configurare MFA le impostazioni utente

L'set-user-mfa-preferenceesempio seguente modifica le opzioni MFA di consegna. Cambia il mezzo MFA di spedizione in. SMS

aws cognito-idp set-user-mfa-preference \ --access-token "eyJra12345EXAMPLE" \ --software-token-mfa-settings Enabled=true,PreferredMfa=true \ --sms-mfa-settings Enabled=false,PreferredMfa=false

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Aggiungere MFA a un pool di utenti nella Amazon Cognito Developer Guide.

Il seguente esempio di codice mostra come utilizzareset-user-settings.

AWS CLI

Per configurare le impostazioni utente

Questo esempio imposta la preferenza MFA di consegna suEMAIL.

Comando:

aws cognito-idp set-user-settings --access-token ACCESS_TOKEN --mfa-options DeliveryMedium=EMAIL

Il seguente esempio di codice mostra come utilizzaresign-up.

AWS CLI

Per registrare un utente

In questo esempio viene registrato jane@example.com.

Comando:

aws cognito-idp sign-up --client-id 3n4b5urk1ft4fl3mg5e62d9ado --username jane@example.com --password PASSWORD --user-attributes Name="email",Value="jane@example.com" Name="name",Value="Jane"

Output:

{ "UserConfirmed": false, "UserSub": "e04d60a6-45dc-441c-a40b-e25a787d4862" }
  • Per API i dettagli, vedere SignUpin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzarestart-user-import-job.

AWS CLI

Per avviare un processo di importazione degli utenti

Questo esempio avvia un processo di input da parte dell'utente.

Per ulteriori informazioni sull'importazione di utenti, vedere Importazione di utenti in pool di utenti da un CSV file.

Comando:

aws cognito-idp start-user-import-job --user-pool-id us-west-2_aaaaaaaaa --job-id import-TZqNQvDRnW

Output:

{ "UserImportJob": { "JobName": "import-Test10", "JobId": "import-lmpxSOuIzH", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548278378.928, "StartDate": 1548278397.334, "Status": "Pending", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0 } }

Il seguente esempio di codice mostra come utilizzarestop-user-import-job.

AWS CLI

Per interrompere un processo di importazione utente

Questo esempio interrompe un processo di input da parte dell'utente.

Per ulteriori informazioni sull'importazione di utenti, vedere Importazione di utenti in pool di utenti da un CSV file.

Comando:

aws cognito-idp stop-user-import-job --user-pool-id us-west-2_aaaaaaaaa --job-id import-TZqNQvDRnW

Output:

{ "UserImportJob": { "JobName": "import-Test5", "JobId": "import-Fx0kARISFL", "UserPoolId": "us-west-2_aaaaaaaaa", "PreSignedUrl": "PRE_SIGNED_URL", "CreationDate": 1548278576.259, "StartDate": 1548278623.366, "CompletionDate": 1548278626.741, "Status": "Stopped", "CloudWatchLogsRoleArn": "arn:aws:iam::111111111111:role/CognitoCloudWatchLogsRole", "ImportedUsers": 0, "SkippedUsers": 0, "FailedUsers": 0, "CompletionMessage": "The Import Job was stopped by the developer." } }

Il seguente esempio di codice mostra come utilizzareupdate-auth-event-feedback.

AWS CLI

Per aggiornare il feedback sugli eventi di autenticazione

Questo esempio aggiorna il feedback sugli eventi di autorizzazione. Contrassegna l'evento come «Valido».

Comando:

aws cognito-idp update-auth-event-feedback --user-pool-id us-west-2_aaaaaaaaa --username diego@example.com --event-id EVENT_ID --feedback-token FEEDBACK_TOKEN --feedback-value "Valid"

Il seguente esempio di codice mostra come utilizzareupdate-device-status.

AWS CLI

Per aggiornare lo stato del dispositivo

Questo esempio aggiorna lo stato di un dispositivo a «not_memored».

Comando:

aws cognito-idp update-device-status --access-token ACCESS_TOKEN --device-key DEVICE_KEY --device-remembered-status "not_remembered"

Il seguente esempio di codice mostra come utilizzareupdate-group.

AWS CLI

Per aggiornare un gruppo

Questo esempio aggiorna la descrizione e la precedenza di MyGroup.

Comando:

aws cognito-idp update-group --user-pool-id us-west-2_aaaaaaaaa --group-name MyGroup --description "New description" --precedence 2

Output:

{ "Group": { "GroupName": "MyGroup", "UserPoolId": "us-west-2_aaaaaaaaa", "Description": "New description", "RoleArn": "arn:aws:iam::111111111111:role/MyRole", "Precedence": 2, "LastModifiedDate": 1548800862.812, "CreationDate": 1548097827.125 } }
  • Per API i dettagli, vedere UpdateGroupin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzareupdate-resource-server.

AWS CLI

Per aggiornare un server di risorse

Questo esempio aggiorna il server di risorse Weather. Aggiunge un nuovo ambito.

Comando:

aws cognito-idp update-resource-server --user-pool-id us-west-2_aaaaaaaaa --identifier weather.example.com --name Weather --scopes ScopeName=NewScope,ScopeDescription="New scope description"

Output:

{ "ResourceServer": { "UserPoolId": "us-west-2_aaaaaaaaa", "Identifier": "weather.example.com", "Name": "Happy", "Scopes": [ { "ScopeName": "NewScope", "ScopeDescription": "New scope description" } ] } }

Il seguente esempio di codice mostra come utilizzareupdate-user-attributes.

AWS CLI

Per aggiornare gli attributi utente

Questo esempio aggiorna l'attributo utente «nickname».

Comando:

aws cognito-idp update-user-attributes --access-token ACCESS_TOKEN --user-attributes Name="nickname",Value="Dan"

Il seguente esempio di codice mostra come utilizzareupdate-user-pool-client.

AWS CLI

Per aggiornare un client del pool di utenti

Questo esempio aggiorna il nome di un client del pool di utenti. Aggiunge anche un attributo scrivibile «nickname».

Comando:

aws cognito-idp update-user-pool-client --user-pool-id us-west-2_aaaaaaaaa --client-id 3n4b5urk1ft4fl3mg5e62d9ado --client-name "NewClientName" --write-attributes "nickname"

Output:

{ "UserPoolClient": { "UserPoolId": "us-west-2_aaaaaaaaa", "ClientName": "NewClientName", "ClientId": "3n4b5urk1ft4fl3mg5e62d9ado", "LastModifiedDate": 1548802761.334, "CreationDate": 1548178931.258, "RefreshTokenValidity": 30, "WriteAttributes": [ "nickname" ], "AllowedOAuthFlowsUserPoolClient": false } }

Il seguente esempio di codice mostra come utilizzareupdate-user-pool.

AWS CLI

Per aggiornare un pool di utenti

Questo esempio aggiunge tag a un pool di utenti.

Comando:

aws cognito-idp update-user-pool --user-pool-id us-west-2_aaaaaaaaa --user-pool-tags Team=Blue,Area=West
  • Per API i dettagli, vedere UpdateUserPoolin AWS CLI Command Reference.