Код: Выделить всё
[HttpGet("GetApplicationToken")]
public async Task GetApplicationToken()
{
HttpClient client = new HttpClient();
var url = "https://login.microsoftonline.com/680ea9b1-xxxx-xxxx-xxxx-xxxxxxxxxxxx/oauth2/v2.0/token";
var parameters = new Dictionary
{
{"client_id", "41d391ef-xxxx-xxxx-xxxx-xxxxxxxxxxxx" },
{"scope", "api://41d391ef-xxxx-xxxx-xxxx-xxxxxxxxxxxx/access_as_user" },
{"client_secret", "PXa8Q~xx" },
{"grant_type", "client_credentials" }
};
var encodedContent = new FormUrlEncodedContent(parameters);
var response = await client.PostAsync(url, encodedContent);
if (response.IsSuccessStatusCode)
{
var responseStr = await response.Content.ReadAsStringAsync();
return Ok(JsonConvert.DeserializeObject(responseStr));
}
return StatusCode(500);
Код: Выделить всё
{"type":"https://tools.ietf.org/html/rfc7231#section-6.6.1","title":"An error occurred while processing your request.","status":500,"traceId":"00-d0da4fd71ec21cb0f8b364e3853bda37-ed1dcd82609eef73-00"}
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/758 ... pplication
Мобильная версия