none
Obtener Token en Solicitud a Rest Api RRS feed

  • Pregunta

  • Hola..

    Ejecuto una solicitud a una Rest Api y me devuelve codigo 200 OK, es decir esta bien pero no se como obtener el token que devuelve

    mi codigo :

      public async Task PostParametrizadoAsync()
            {
                HttpClient client = new HttpClient();
                System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://idp.comprobanteselectronicos.go.cr/auth/realms/rut-stag/protocol/openid-connect/token");
                var formData = new List<KeyValuePair<string, string>>();
                formData.Add(new KeyValuePair<string, string>("client_id", "api-stag"));
                formData.Add(new KeyValuePair<string, string>("grant_type", "password"));
                formData.Add(new KeyValuePair<string, string>("username", "fsf3242@stag.comprobanteselectronicos.go.cr"));
                formData.Add(new KeyValuePair<string, string>("password", "fsdfs34234"));
                formData.Add(new KeyValuePair<string, string>("scope", ""));
                request.Content = new FormUrlEncodedContent(formData);
                var response = await client.SendAsync(request);
                richTextBox1.Text = response.ToString();
            }

    me devuelve

    StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Transfer-Encoding: chunked
      Connection: keep-alive
      CF-RAY: 3c99d07f6d3d50c8-MIA
      Date: Thu, 07 Dec 2017 19:15:35 GMT
      Set-Cookie: __cfduid=dfca86d4feeaaaabb7395544081a3d8f61512674135; expires=Fri, 07-Dec-18 19:15:35 GMT; path=/; domain=.comprobanteselectronicos.go.cr; HttpOnly
      Server: cloudflare-nginx
      X-Powered-By: Undertow/1
      Content-Type: application/json
    }


    EFRAIN MEJIAS C VALENCIA - VENEZUELA

    jueves, 7 de diciembre de 2017 19:16

Respuestas