By using AWS re:Post, you agree to the Terms of Use

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 Answer
2
Accepted Answer

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 picture
answered 2 months ago
  • Thank you so much! You saved dozens of hours of searching for a solution

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions