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 Respuesta
2
Respuesta aceptada

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
respondido hace 2 años
  • Thank you so much! You saved dozens of hours of searching for a solution

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas