public async Task<string> LoginAsTaxPayer(string _dataAreaId){ MYParameter mYParameter = new MYParameter(); mYParameter = MYParameter.findByComp(_dataAreaId,true); if (mYParameter.Found) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(https:/// + mYParameter.BaseURL + //connect/token/); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(/application/x-www-form-urlencoded/)); var form = new Dictionary<string, string> { {/client_id/, mYParameter.ClientID}, {/client_secret/, mYParameter.ClientSecret}, {/grant_type/, /client_credentials/}, {/scope/,// } }; var response = await client.PostAsync(client.BaseAddress, new FormUrlEncodedContent(form)); if (response.IsSuccessStatusCode) { string respBody=response.Content.ReadAsStringAsync().Result; Token mytoken = JsonConvert.DeserializeObject<Token>(respBody); mYParameter.AccessToken = mytoken.AccessToken; mYParameter.Update(); return response.StatusCode.ToString(); } else { string respBody = response.Content.ReadAsStringAsync().Result; ErrResponse errResp = JsonConvert.DeserializeObject<ErrResponse>(respBody); return errResp.Error_Descr; } } } else { return /No Parameter found/; } }
Teh