Я не могу обновить токен доступа после его истечения.Я не уверен, что не так, и я следовал согласно документации.Я использую сервис WCF и получаю сообщение об ошибке ниже.
{StatusCode: 400, ReasonPhrase: 'Bad Request', версия: 1.1, Content: System.Net.Http.StreamContent, заголовки: {Соединение: keep-alive
x-frame-опции: SAMEORIGIN X-XSS-Protection: 1;mode = block
X-Content-Type-Options: nosniff Expect-CT: max-age = 604800, report-uri = "https://report -uri.cloudflare.com / cdn-cgi / beacon / wait-ct"CF-RAY: 4294254a0b608a9d-BOM Cache-Control: no-store Дата: Пн, 11 июня 2018 12:40:21 GMT Set-Cookie: __cfduid = d9ac433a81ce1ec1aedad217862472b131528720820;истекает = вт, 11 июня - 19 часов 12:40:20 по Гринвичу;Путь = /;домен = .lightspeedapp.com;HttpOnly;Защищенный сервер: cloudflare Длина содержимого: 69 Тип содержимого: application / json}}
public string RefreshToken(string clientsecretkey, string clientkey, string refreshToken)
{
string newToken = "";
int expTime = 0;
string scope = "";
string type = "";
try
{
using (var client = new HttpClient())
{
using (var content = new MultipartFormDataContent())
{
var values = new[]
{
new KeyValuePair<string, string>("refresh_token", refreshToken),
new KeyValuePair<string, string>("client_id",clientkey),
new KeyValuePair<string, string>("client_secret",clientsecretkey),
new KeyValuePair<string, string>("grant_type", "refresh_token")
};
foreach (var keyValuePair in values)
{
content.Add(new StringContent(keyValuePair.Value), keyValuePair.Key);
}
var fileContent = new ByteArrayContent(new byte[100]);
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = "Foo.txt"
};
content.Add(fileContent);
var requestUri = "https://cloud.lightspeedapp.com/oauth/access_token.php";
HttpResponseMessage result = client.PostAsync(requestUri, content).Result;
if (result.StatusCode == HttpStatusCode.OK)
{
var smessage = result.Content.ReadAsAsync<UserCredentials>(new[] { new JsonMediaTypeFormatter() }).Result;
if (smessage != null)
{
newToken = smessage.AccessToken;
expTime = smessage.ExpiresIn;
scope = smessage.Scope;
type = smessage.TokenType;
}
}
}
}
}