I have completed web part of my Project and deployed my website on azure. My project is designed on Web API Entity Framework. Now I need to design Mobile App of my project Cross Platform Xamarin. I know basics of Xamarin development but having difficulties in Login part. Following this tutorial I have done the followings
ApiServices.cs
public async Task LoginAsync(string userName, string password) { var keyValues = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("username",userName), new KeyValuePair<string, string>("password",password), new KeyValuePair<string, string>("grant_type","password"), }; var request = new HttpRequestMessage(HttpMethod.Post, "http://epolleasy.azurewebsites.net/Token"); request.Content = new FormUrlEncodedContent(keyValues); var client = new HttpClient(); var response = await client.SendAsync(request); var content = await response.Content.ReadAsStringAsync(); Debug.WriteLine(content); }LoginViewModel.cs
public class LoginViewModel { private ApiServices _apiServices = new ApiServices(); public string Username { get; set; } public string Password { get; set; } public ICommand LoginCommand { get { return new Command(async() => { await _apiServices.LoginAsync(Username, Password); }); } } }LoginPage.xaml
<StackLayout> <Entry Text="{Binding Username}" Placeholder="Username"/> <Entry Text="{Binding Password}" IsPassword="True" Placeholder="Password"/> <Button Command="{Binding LoginCommand}" Text="Login"/> <Button Text="Signup" Clicked="Button_OnClicked"/> </StackLayout>
The problem is, this all only generates a token just as shown in tutorial. I want to know what i need to do with this token or how can I get user to login in my application using my builtin project web APIs. I searched a lot but unable to find any good tutorial regarding this topic.
httpSsince yourpasswordis plain-text