コード例 #1
0
        private tokenCredential GetToken(apiCredential apiCredential, loginViewModel credentialLogin)
        {
            ApiConsumer         api      = new ApiConsumer(apiCredential);
            HttpResponseMessage Response = ApiConsumer.PostApiAsync <loginViewModel>(credentialLogin);

            return(parameters.convertJsonToClass <tokenCredential>(Response));
        }
コード例 #2
0
 public ApiConsumer(apiCredential apiCredential)
 {
     _URI    = apiCredential.URI;
     _method = apiCredential.method;
     _Port   = apiCredential.port;
     _RequeridAuthorization = apiCredential.RequeridAuthorization;
     _URI               = apiCredential.FullUri;
     _token             = apiCredential.token;
     result             = new HttpResponseMessage();
     client             = new HttpClient();
     client.BaseAddress = new Uri(_URI);                                                        // send Url To app
     client.DefaultRequestHeaders.Clear();
     client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(contentType)); // Send content type to Api
     if (_RequeridAuthorization)
     {
         client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token);
     }
 }