getUserAttributes method
This is used by authenticated users to get a list of attributes
Implementation
Future<List<CognitoUserAttribute>?> getUserAttributes() async {
if (!(_signInUserSession != null && _signInUserSession!.isValid())) {
throw Exception('User is not authenticated');
}
final paramsReq = {
'AccessToken': _signInUserSession!.getAccessToken().getJwtToken(),
};
final userData = await client!.request('GetUser', paramsReq);
if (userData['UserAttributes'] == null) {
return null;
}
final attributeList = <CognitoUserAttribute>[];
userData['UserAttributes'].forEach((attr) {
attributeList
.add(CognitoUserAttribute(name: attr['Name'], value: attr['Value']));
});
return attributeList;
}