0

Currently developing an ASP.Net Core 6 API to be consumed from a Xamarin mobile app.

I just want to know two things :

  • What ASP.Net Core Web API authentication must I use? Jason Web Token (JWT) or another type of authentication suitable for Xamarin Mobile as per below image.

  • How do I keep (JWT) cookies authentication alive and kill it after then pass it on endpoint through to the mobile developer so they can use it and cancel it from the Xamarin app or it will be done automatically ?

  • How do I pass the JWT token from the ASP.Net Core API to the Xamarin App... because the Web API will be consumed from an Xamarin Mobile App.

Any idea please ?

private static async Task ProcessRepositories()
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/vnd.test.v3+json"));
client.DefaultRequestHeaders.Add("User-Agent", "crmsystem Repository Reporter");
var stringTask = client.GetStringAsync("https://api.crm.com/data/repo");
var msg = await stringTask;
Console.Write(msg);
}
4
  • Firstly, you could use JWT token without any hesitation its more used and secure authentication protocol now, regarding cookie authentication you could set token life time there. After that particular time token would be expire automatically. You could have a look here in official document Commented Nov 16, 2021 at 2:37
  • @MdFaridUddinKiron Thank you for your help. How do I pass the JWT token from the ASP.Net Core API to the Xamarin App... because the Web API will be consumed from an Xamarin Mobile App. Commented Nov 16, 2021 at 18:31
  • Hello is there anything else that I can help you with? Commented Nov 18, 2021 at 1:34
  • @MdFaridUddinKiron Not at all. You replied exactly what I was looking for. Thank you for your assistance. Commented Nov 23, 2021 at 6:59

1 Answer 1

2
  • What ASP.Net Core Web API authentication must I use? Jason Web Token (JWT) or another type of authentication suitable for Xamarin Mobile as per below image.

You could use JWT token without any hesitation its more used and secure authentication protocol now. Here is the example

  • How do I keep (JWT) cookies authentication alive and kill it after then pass it on endpoint through to the mobile developer so they can use it and cancel it from the Xamarin app or it will be done automatically

Regarding cookie authentication you could set token life time there. After that particular time token would be expire automatically. You could have a look here in official document

  • How do I pass the JWT token from the ASP.Net Core API to the Xamarin App... because the Web API will be consumed from an Xamarin Mobile App. Steps are

Step:1 Login/Authentication controller: Your API should have Authentication controller which is check user login attempt and generate token. you can read more on official document

Step:2 Request Login API for getting token: You have to call this API from your Xamarin app taking user Id and password from User login Form which it return you the token. Here is the sample code

Step:3 Pass Bearer Token to Access Data: Finally, use token for any kind of request to API. You can have look on our official docs here

Sign up to request clarification or add additional context in comments.

2 Comments

Very very well explained Sir. Thank you so so much for your reply. Do you have any book or blog you wrote about tech so I can start following you please?
Not really, your scope is little bigger to answer. If you could split it in a small chunk in diffrent questions instead of a single question so that it will be easier to answer. question that not specific answering those question cause downvote sometimes. So would you kindly split your question so that it can be focus on one specific problem. Because it a long topic, I will try provide you guidelines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.