TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
William Lay
NA
31
2.9k
Cognito and ASP.NET C# problem
Nov 18 2020 11:05 PM
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.
Reply
Answers (
2
)
how to read Web APi csv file
About keeping session alive in mvc