Guest User

Untitled

a guest
Apr 5th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <add name="DefaultConnection" connectionString="Data Source=192.168.1.106; Initial Catalog=Gesuro; Integrated Security=True; User ID = sergio; Password=xxxxxxxx" providerName="System.Data.SqlClient" />
  2.  
  3. var token = await this.apiService.GetToken(
  4. "http://localhost:50965",
  5. this.Email,
  6. this.Password);
  7.  
  8. public async Task<TokenResponse> GetToken(
  9. string urlBase,
  10. string username,
  11. string password)
  12. {
  13. try
  14. {
  15. var client = new HttpClient();
  16. client.BaseAddress = new Uri(urlBase);
  17. var response = await client.PostAsync("Token",
  18. new StringContent(string.Format(
  19. "grant_type=password&username={0}&password={1}",
  20. username, password),
  21. Encoding.UTF8, "application/x-www-form-urlencoded"));
  22. var resultJSON = await response.Content.ReadAsStringAsync();
  23. var result = JsonConvert.DeserializeObject<TokenResponse>(
  24. resultJSON);
  25. return result;
  26. }
  27. catch (Exception e)
  28. {
  29. var pepe = e.Message;
  30. return null;
  31. }
  32. }
Add Comment
Please, Sign In to add comment