/// <summary> /// Add custom attributes if not yet setup /// </summary> private async Task InitializeCustomAttributes() { var userPoolRequest = new DescribeUserPoolRequest { UserPoolId = CognitoUserPoolId }; DescribeUserPoolResponse userPoolInfo = await Cognito.DescribeUserPoolAsync(userPoolRequest); var customAttributes = new List <SchemaAttributeType>(); var companyAttr = new SchemaAttributeType { AttributeDataType = AttributeDataType.String, Name = CompanyNameAttribute }; List <SchemaAttributeType> userPoolSchemaAttributes = userPoolInfo.UserPool.SchemaAttributes; if (userPoolSchemaAttributes.All(a => a.Name != companyAttr.Name)) { customAttributes.Add(companyAttr); } if (customAttributes.Count > 0) { _logger.LogInformation($"Adding custom Cognito Attributes {CompanyNameAttribute}"); await Cognito.AddCustomAttributesAsync( new AddCustomAttributesRequest { CustomAttributes = customAttributes, UserPoolId = CognitoUserPoolId }); } }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { DescribeUserPoolResponse response = new DescribeUserPoolResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("UserPool", targetDepth)) { var unmarshaller = UserPoolTypeUnmarshaller.Instance; response.UserPool = unmarshaller.Unmarshall(context); continue; } } return(response); }