ในโค้ดด้านล่าง ฉันสามารถดึงโทเค็นการรีเฟรชได้จากที่อยู่อีเมล [email protected] อย่างไรก็ตาม เมื่อฉันพยายามเข้าสู่ระบบด้วย [email protected] มันไม่ให้โทเค็นการรีเฟรช แต่กลับตอบกลับมา
การตอบสนอง:
{
"error": "invalid_grant",
"error_description": "AADSTS70000: The provided value for the 'code' parameter is not valid. The code has expired.\r\nTrace ID: ...\r\nCorrelation ID: ...\r\nTimestamp: 2016-05-19 10:13:05Z",
"error_codes": [
70000
],
"timestamp": "2016-05-19 10:13:05Z",
"trace_id": "8cceb393-....",
"correlation_id": "5227de8...."
}
รหัส:
private async Task<string> GetRefreshRoken(string authCode, string onSuccessRedirectUri) {
var client = new HttpClient();
var parameters = new Dictionary<string, string>
{
{"client_id", _clientId},
{"client_secret", _clientSecret},
{"code",authCode }, // what retreived from //https://login.microsoftonline.com/common with authroization.
{"redirect_uri", onSuccessRedirectUri}, //http://localhost:27592/Home/Authorize
{"grant_type","authorization_code" }
};
var content = new FormUrlEncodedContent(parameters);
var response = await client.PostAsync("https://login.microsoftonline.com/common/oauth2/v2.0/token", content);
var tokensJsonString = await response.Content.ReadAsStringAsync();
dynamic token = Newtonsoft.Json.JsonConvert.DeserializeObject(tokensJsonString);
return token.refresh_token;
}
ดังนั้นฉันจึงค้นหาหมายเลขข้อผิดพลาดใน Google และพบ http://www.matvelloso.com/2015/01/30/troubleshooting-common-azure-active-directory-errors/ หน้าที่อธิบายข้อผิดพลาด:
จากนั้นฉันได้เปลี่ยน URL การเปลี่ยนเส้นทางเป็น "http://localhost:27592/Home/Authorize/ ". เนื่องจากฉันใช้ https://dev.outlook.com/restapi/tutorial/dotnet บทช่วยสอนเป็นข้อมูลอ้างอิง ตอนนี้ฉันไม่สามารถเข้าสู่ระบบด้วยบัญชีอื่นได้
มีวิธีที่ดีในการดึงโทเค็นการรีเฟรชสำหรับบัญชี Outlook หรือไม่?