Closed andsee closed 5 years ago
Can you make sure you have followed this tutorial: https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/welcome.html
You will need a credential file for developing with the AWS SDK for .NET. This is done by installing the AWS Toolkit for Visual Studio and creating a "default" profile:
https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html
https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-creds.html
Also, the original blog post is aimed at showing how to integrate an existing .net core web app with Cognito. You can pull the samples project and have a look at it, especially how the new Managers are injected and used in the Identity Controllers.
To add on to what @assyadh said, the AWS toolkit is much easier to use.
Keep in mind this builds on the AWS SDK, which means you need to install the AWS Toolkit and create a default profile that this will use. Its based on an IAM user that you create in your AWS IAM section. I created that has a policy for CognitoPowerUser.
Then switch to the SECURITY CREDNETIALS tab and generate a key, there you can download a CSV file with the key and secret for that IAM user. You only get one shot to get the secret, once you leave the page you cant get it again and you have to make a new key.
Then take that key and import it into you AWS EXPLORER that you installed into Visual Studio:
Make sure your profile is called "default". Once that is setup, you should be able to browse all AWS the items and switch regions. If that works then you can try to run your app again and it will function.
For your second issue where it complains you need a login page...If you use VS 2017, that's the Microsoft Core 2.0 Identity provider. If you create a new project in .NET and choose AUTHENITCATION = INDIVIDUAL ACCOUNTS, this folder is created. Then you can scaffold in (have VS create all those pages for you) the irequired identity pages. Keep in mind this library overrides the default MS identity so you can access cognito using the identity provider and those pages. There are several changes you need to make which they have documented in the samples. Keep in ind the samples are done in Razor pages and not regular MVC.
Thanks for the quick replies. I do and did have AWS tookit installed with a default user (The project I am trying to add it to already uses RDS, Elasticache & CloudWatch). However the user did not specifically have the AmazonCognitoPowerUser permissions so I've added them, but this has made no difference. I still get the same error.
Regarding the 2nd part, I was trying to add it to an existing project in visual studio 2017 which uses cognito via AddOpenIdConnect. Not quite sure if I can rescaffold an existing project to add the relevant files so I thought I would check out the sample and try to manually spot the differences.
But unfortunately a clean pull of the project adding the aws settings and I still get the same error:
Of note the cognito settings are pulled from a working app using the .net SDK within Unity3D, so cognito should be correctly configured fingers crossed.
Would you mind sharing how your config file looks like, Please make sure to REMOVE any secrets, it looks like some parsing is not going well
Thank for continuing to look into this for me. Here is the appsettings.json
The above appsettings is from the app I tried adding cognito to the following appsettings.zip is the one I'm using within the sample
I get the same error when using a malformed json with dummy string values such as:
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"AWS": {
"Region": "<your region id goes here>",
"UserPoolClientId": "<your user pool client id goes here>",
"UserPoolClientSecret": "<your user pool client secret goes here>",
"UserPoolId": "<your user pool id goes here>"
}
}
UriFormatException: Invalid URI: The hostname could not be parsed.
Are you sure you are editing the appsettings.Development.json and not the appsettings.json?
The appsettings.Development.json is the one loaded while running the app inside Visual Studio
Are you sure you are editing the appsettings.Development.json and not the appsettings.json?
I was having this issue and this was my problem.
Closing this. Please use the appsettings.Development.json :)
I too ran into this issue, then quickly realized (thanks to this thread) that I need to modify the settings in appSettings.Development.json. I suggest dropping a readme.md into https://github.com/aws/aws-aspnet-cognito-identity-provider/tree/master/samples directing developers to do the step, it would save a bit of time :)
Perhaps there are some extra configuration steps I need to do. I've cloned the repository and added the aws settings to appsettings.json but I get the following error when running in visual studio:
UriFormatException: Invalid URI: The hostname could not be parsed. System.Uri.CreateThis(string uri, bool dontEscape, UriKind uriKind) Amazon.Runtime.ClientConfig.GetUrl(RegionEndpoint regionEndpoint, string regionEndpointServiceName, bool useHttp, bool useDualStack) in ClientConfig.cs Amazon.Runtime.ClientConfig.DetermineServiceURL() in ClientConfig.cs Amazon.Runtime.Internal.DefaultRetryPolicy..ctor(IClientConfig config) in DefaultRetryPolicy.cs Amazon.Runtime.AmazonServiceClient.BuildRuntimePipeline() in AmazonServiceClient.cs
I also tried following the instructions here https://aws.amazon.com/blogs/developer/introducing-the-asp-net-core-identity-provider-preview-for-amazon-cognito/ to the point where my site was complaining about no login page when run. I notice the sample has a Identity Area with the pages in. I'm not sure why the post does not explain whatever extra steps need to be done to add these.
Looking forward to getting this integrated.