Hello guys!
We are from ClepIO’s development group (
https://clep.io/).
We are trying to make our very first request to get the tokens so we can make a legit access later. This is a multi-platform system so we must get the device tokens first.
But, when we try to get the response from the server, we get this:
<html>
<head><title>Document moved</title></head>
<body><h1>Document moved</h1>
This document has moved <a href="
http://cloud.vitadock.com/auth/spring_security_login">here</a>.<p>
</body>
</html>
Even if we try to log in that url of above, manually and with our registered account, we get this message:
Your login attempt was not successful, try again.
Reason: No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken
So, the thing is, how are we supposed to get the tokens? Is there any issue with the servers right now? We really need to go on with this merging, so any kind of help will be highly appreciated.
The code we are using is the one that follows:
public static string GetoAuthDeviceToken()
{
string oauth_nonce = "";
string oauth_signature = "";
string timestamp = "";
string method = "POST";
string consumerKey = ConfigurationManager.AppSettings["MedisanaApplicationToken"];
string consumerSecret = ConfigurationManager.AppSettings["MedisanaApplicationSecret"];
string uri = "
https://cloud.vitadock.com/auth/devices";
string signatureMethod = "HMAC-SHA256";
// Default implementation of UNIX time of the current UTC time --> Adapted to Medisana
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
//Calcular oauth_nonce
Random random = new Random();
oauth_nonce = Guid.NewGuid().ToString() + timestamp;
string cadena = "oauth_nonce=\"" + oauth_nonce + "\"&oauth_timestamp=\"" + timestamp +
"\"&oauth_version=\"1.0\"&oauth_signature_method=\"" + signatureMethod +
"\"&oauth_consumer_key =\"" + consumerKey + "\"";
string cadenaEncode = EncodeUtils.EncodeRFC3986(cadena);
string uriEncode = EncodeUtils.EncodeRFC3986(uri);
//Calcular oauth_signature
string signatureBaseString = method + "&" + uriEncode + "&" + cadenaEncode;
string signatureKey = consumerSecret + "&";
byte[] hashValue64 = EncodeUtils.EncodeHMACSHA256(signatureBaseString, signatureKey);
oauth_signature = Convert.ToBase64String(hashValue64);
//Get url
string url = uri + "&oauth_nonce=\"" + oauth_nonce + "\"&oauth_timestamp=\"" + timestamp +
"\"&oauth_version=\"1.0\"&oauth_signature_method=\"" + signatureMethod +
"\"&oauth_consumer_key =\"" + consumerKey + "&oauth_signature=\"" + oauth_signature + "\"";
// Create a request using a URL that can receive a post.
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
request.AllowAutoRedirect = false;
// Set the Method property of the request to POST.
request.Method = method;
//request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "application/json";
request.Headers.Add("Authorization", "OAuth oauth_nonce=\"" + oauth_nonce + "\",oauth_timestamp=\"" + timestamp +
"\",oauth_version=\"1.0\",oauth_signature_method=\"" + signatureMethod + "\"oauth_consumer_key =\"" + consumerKey +
"oauth_signature=\"" + oauth_signature + "\"");
request.Headers.Add("device_id", "00001");
HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
string result = sr.ReadToEnd().Trim();
return result;
}
Does anyone have the same issue? Maybe is it something that we are not building properly?
Thanks in advance!