Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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" />
- var token = await this.apiService.GetToken(
- "http://localhost:50965",
- this.Email,
- this.Password);
- public async Task<TokenResponse> GetToken(
- string urlBase,
- string username,
- string password)
- {
- try
- {
- var client = new HttpClient();
- client.BaseAddress = new Uri(urlBase);
- var response = await client.PostAsync("Token",
- new StringContent(string.Format(
- "grant_type=password&username={0}&password={1}",
- username, password),
- Encoding.UTF8, "application/x-www-form-urlencoded"));
- var resultJSON = await response.Content.ReadAsStringAsync();
- var result = JsonConvert.DeserializeObject<TokenResponse>(
- resultJSON);
- return result;
- }
- catch (Exception e)
- {
- var pepe = e.Message;
- return null;
- }
- }
Add Comment
Please, Sign In to add comment