Amazon Cognito: how to change the Endpoint in AWS SDK .NET?

0

I want to protect my Cognito public WPF client using an Amazon CloudFront proxy. For this I followed this guide: https://aws.amazon.com/ru/blogs/security/protect-public-clients-for-amazon-cognito-by-using-an-amazon-cloudfront-proxy/

Now I need to change the Endpoint in my client application to use the CloudFront distribution domain name. Sorry for my cluelessness but I have not found a place where I can do this in AWS SDK for .NET.

There are examples how to change the Endpoint in the tutorial above however they are intended for Amazon Cognito Identity SDK for JavaScript, AWS Amplify but not for the AWS SDK for .NET.

The questions are as follows: is it possible to change the Endpoint in Amazon.CognitoIdentityProvider in AWS SDK for .NET? If so, how can I do this?

1개 답변
2
수락된 답변

There is a way to specify a custom endpoint for virtually every service client of the .NET SDK. Please refer to the SDK documentation.

You can use the ServiceURL property of a configuration object you pass when instantiating a client.

using Amazon.CognitoIdentityProvider;

// ...

var config = new AmazonCognitoIdentityProviderConfig
{ 
    ServiceURL = "https://your-endpoint" 
};

var provider = new AmazonCognitoIdentityProviderClient(config);

This technique works if the endpoint doesn't follow the regular Region endpoint pattern.

If you are using the extensions from Amazon.Extensions.NETCore.Setup, you can specify the endpoint in your global client factory:

var options = new AWSOptions();
options.DefaultClientConfig.ServiceURL = "https://your-endpoint";

// ...

var provider = options.CreateServiceClient<AmazonCognitoIdentityProviderClient>();
profile pictureAWS
답변함 2년 전
  • Thank you so much! You saved dozens of hours of searching for a solution

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인