I have been trying to get the session and the details of the current user after he has successfully logged in into the system as seen in the code below. However, I am not very sure how to get the session and details of the current user, the one i saw was through Javascript. Is there any way to use ASP.NET C# code to get those details?
Here is my code :
- const string PoolID = "id";
- const string ClientID = "id";
- static Amazon.RegionEndpoint Region = Amazon.RegionEndpoint.USEast1;
- protected void Page_Load(object sender, EventArgs e)
- {
- string username = "1";
- string password = "2";
- string email = "3";
- SignInUser(username,password);
- }
- static async Task<int> SignInUser(string username, string password)
- {
- AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), Region);
-
- CognitoUserPool userPool = new CognitoUserPool(PoolID, ClientID, provider);
-
- CognitoUser user = new CognitoUser(username, ClientID, userPool, provider);
-
- InitiateSrpAuthRequest authRequest = new InitiateSrpAuthRequest()
- {
- Password = password
- };
-
- AuthFlowResponse authResponse = null;
- try
- {
- authResponse = await user.StartWithSrpAuthAsync(authRequest).ConfigureAwait(false);
- }
-
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine("Logon Failed: {0}\n", ex.Message);
- return 0;
- }
-
- GetUserRequest getUserRequest = new GetUserRequest();
- getUserRequest.AccessToken = authResponse.AuthenticationResult.AccessToken;
-
- System.Diagnostics.Debug.WriteLine(authResponse.AuthenticationResult.AccessToken);
- System.Diagnostics.Debug.WriteLine("Logon Successful");
- return 1;
- }
Any help will be appreciated. Thank You.