Beispiel #1
0
        public async Task <ResponseBody> LoginAsync(string login, string password)
        {
            var client = new HttpClient();

            var LoginModel = new LoginWithCredentialsRequest
            {
                Login        = login,
                Password     = password,
                ClientId     = "MOBILE",
                ClientSecret = "UNIV"
            };
            var json = JsonConvert.SerializeObject(LoginModel);

            HttpContent content = new StringContent(json);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var response = await client.PostAsync("https://pizza.julienmialon.ovh/api/v1/authentication/credentials", content);

            var jsonResponse = await response.Content.ReadAsStringAsync();

            Debug.WriteLine(content);

            ResponseBody responseBody = JsonConvert.DeserializeObject <ResponseBody>(jsonResponse);

            return(responseBody);
        }
 public async Task <IActionResult> LoginWithCredentials([FromBody] LoginWithCredentialsRequest request)
 {
     return(await Action <LoginWithCredentialsCommand, LoginWithCredentialsCommandParameter, LoginResponse>(new LoginWithCredentialsCommandParameter
     {
         Login = request.Login,
         Password = request.Password,
         ClientId = request.ClientId,
         ClientSecret = request.ClientSecret
     }));
 }
Beispiel #3
0
        public async Task <Response <LoginResponse> > Connect(string login, string password, string clientid, string clientsecret)
        {
            LoginWithCredentialsRequest log = new LoginWithCredentialsRequest
            {
                ClientId     = clientid,
                ClientSecret = clientsecret,
                Login        = login,
                Password     = password
            };
            string content = JsonConvert.SerializeObject(log);

            return(await _apiService.Post <Response <LoginResponse> >(Urls.LOGIN_WITH_CREDENTIALS, content));
        }
 public async Task <Response <LoginResponse> > Login(LoginWithCredentialsRequest user)
 {
     return(await _apiService.Post <Response <LoginResponse> >(Urls.LOGIN_WITH_CREDENTIALS, user));
 }