AADSTS90102: 'redirect_uri' Wert muss eine gültige absolute Uri
Ich bin nach der Anleitung von diese Seite. Ich habe mir ein windows-Dienst und ich bin am stecken, die einen Zugriff anfordern token von Azure AD.
Ich schaffte es, ein Autorisierungs-code, aber ich bekomme die redirect_uri Fehler, wenn ich POST. Dies ist, was mein code sieht wie folgt aus:
var dictionary = new Dictionary<string, string>
{
{ "resource", "https%3A%2F%2Foutlook.office365.com"},
{"client_id","Application ID from azure AD portal" }, //-is this ok?
{"client_secret","Object ID from azure AD portal" }, //-is this ok?
{"grant_type","authorization_code" },
{"redirect_uri",HttpUtility.UrlEncode("https://haw.trustteam.be/") },
{ "code","AQABAAIAAAAB..1AiAA"}
};
var content = new FormUrlEncodedContent(dictionary);
string requestUrl = "https://login.windows.net/common/oauth2/token"; //also tried with login.microsoftonline.com
using (HttpClient client = new HttpClient())
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUrl);
request.Content = content;
using (HttpResponseMessage response = await client.SendAsync(request))
{
string responseString = await response.Content.ReadAsStringAsync();
return response.Content.ToString();
}
}
Was mache ich falsch?
Du musst angemeldet sein, um einen Kommentar abzugeben.
FormUrlEncodedContent Funktion auch helfen, buchen die Daten in der HttpMessage Körper als url-codierte Schlüssel/Wert-Paaren. So entfernen Sie die
HttpUtility.UrlEncode
Funktion:Darüber hinaus können Sie add-client-Geheimnis in
Keys
Klinge von Ihrem azure ad application . Bitte dieses Dokument .