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

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则