Unable to authenticate Office add-in using Dialog API and ADAL.
I am trying to authenticate a user using Dialog API and ADAL. The Dialog is opening fine, but I am receiving error that the reply url specified in the request does not match the reply urls configured for the application. The reply url is configured as the dialog URL both in the code as well as in App Registration.
$("#btnSignin").click(function () {
var url = "https://localhost:44367/auth.html";
Office.context.ui.displayDialogAsync(url, { height: 40, width: 40 }, function (result) {
_dlg = result.value;
_dlg.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, dialogMessageReceived);
});
});
The URL - https://localhost:44367/auth.html is configured as the redirectUri and while debugging also authcontext.config.redirectUri points to https://localhost:44367/auth.html?_host_Info=Excel$Win32$16.01$en-US$telemetry$isDialog".
I am not sure why it is giving the error, though the urls are configured correctly.Is there anyother redirectUri to be added ?
This is a bit to complicated to put in a comment, so I'll use an "answer" for now.
Where are you seeing the error? In a JavaScript console? In a popup?
Please open the raw manifest of the app registration in the Azure portal and see what is the value of the
replyUrlsWithTypeproperty.Please use the Fiddler tool to see the HTTP Request that is going to the login URL:
https://login.microsoftonline.com/{YOUR O365 TENANCY GUID}/oauth2/v2.0/authorize?scope={VARIOUS SCOPES}&response_type=code&client_id={YOUR APP'S REGISTRATION ID IN AAD}&redirect_uri={YOUR LOCALHOST REDIRECT URL}What is the exact string that is being sent as the
redirect_uri? It will be URL-encoded, but otherwise it should match what's in the raw manifest.