I try to connect to the following address to obtain a token, I try it in the following ways, but in all of them I get a query error, these are the examples I use for the query and the routes as they are created:
string client_id = "api-stag";// CLIENT ID = api-stag
string client_secret = "";// CLIENT SECRET = [VACIO]
string scope = "";// SCOPE = [VACIO]
string url = "https://idp.comprobanteselectronicos.go.cr/auth/realms/rut-stag/protocol/openid-connect/token/" + "?CLIENT ID={" + client_id + "}&CLIENT SECRET={" + client_secret + "}&SCOPE={" + scope + "}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
try with the following code in the same way:
string client_id = "api-stag";// CLIENT ID = api-stag
string client_secret = "";// CLIENT SECRET = [VACIO]
string scope = "";// SCOPE = [VACIO]
byte[] data = Encoding.ASCII.GetBytes($"CLIENT ID={client_id}&CLIENT SECRET={client_secret}&SCOPE={scope}");
WebRequest request = WebRequest.Create("https://idp.comprobanteselectronicos.go.cr/auth/realms/rut-stag/protocol/openid-connect/token");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
string responseContent = null;
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
using (StreamReader sr99 = new StreamReader(stream))
{
responseContent = sr99.ReadToEnd();
}
}
}
MessageBox.Show(responseContent);
I created the following links, but none works, in these ways or other proven
"https://idp.comprobanteselectronicos.go.cr/auth/realms/rut-stag/protocol/openid-connect/token/?CLIENT ID={api-stag}&CLIENT SECRET={}&SCOPE={}"
"https://idp.comprobanteselectronicos.go.cr/auth/realms/rut-stag/protocol/openid-connect/token/?CLIENT_ID={api-stag}&CLIENT_SECRET={}&SCOPE={}"
"https://idp.comprobanteselectronicos.go.cr/auth/realms/rut-stag/protocol/openid-connect/token/?CLIENT_ID=api-stag&CLIENT_SECRET=&SCOPE="
"https://idp.comprobanteselectronicos.go.cr/auth/realms/rut-stag/protocol/openid-connect/token/?CLIENT_ID='api-stag'&CLIENT_SECRET=''&SCOPE=''"