要获取通过SAML身份验证传递的自定义属性,需要在响应中添加以下配置:
$cognitoClient = new CognitoIdentityProviderClient([
'version' => '2016-04-18',
'region' => '',
]);
$cognitoUser = $cognitoClient->getUser([
'AccessToken' => '',
]);
$customAttributes = array_filter($cognitoUser->getUserAttributes(), function($attribute) {
return $attribute->getName() == 'customAttributeName';
});
请注意,要将“customAttributeName”替换为在Cognito中定义的实际自定义属性名称。