title: Xamarin forms application login using ASP.Net Web API
body: <p>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 <a href="https://www.youtube.com/watch?v=Nkccb9ODr_A" rel="nofollow noreferrer">this tutorial</a> I have done the followings </p>
  
  <ol>
  <li><p>ApiServices.cs</p>
  
  <pre><code>public async Task LoginAsync(string userName, string password)
  {
      var keyValues = new List&lt;KeyValuePair&lt;string, string&gt;&gt;
      {
          new KeyValuePair&lt;string, string&gt;("username",userName),
          new KeyValuePair&lt;string, string&gt;("password",password),
          new KeyValuePair&lt;string, string&gt;("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);
  }  
  </code></pre></li>
  <li><p>LoginViewModel.cs</p>
  
  <pre><code>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() =&gt;
          {
              await _apiServices.LoginAsync(Username, Password);
          });
      }
  }
  }
  </code></pre></li>
  <li><p>LoginPage.xaml</p>
  
  <pre><code>&lt;StackLayout&gt;
  &lt;Entry Text="{Binding Username}" Placeholder="Username"/&gt;
  &lt;Entry Text="{Binding Password}" IsPassword="True" Placeholder="Password"/&gt;
  &lt;Button Command="{Binding LoginCommand}" Text="Login"/&gt;
  &lt;Button Text="Signup" Clicked="Button_OnClicked"/&gt;
  &lt;/StackLayout&gt;
  </code></pre></li>
  </ol>
  
  <p>The <strong>problem</strong> 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. </p>