Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Dialog error 12002 #41

Closed
GregPartner opened this issue Aug 29, 2017 · 8 comments
Closed

Dialog error 12002 #41

GregPartner opened this issue Aug 29, 2017 · 8 comments

Comments

@GregPartner
Copy link

I started new office JS project , the default Word sample, removed all code in Office.initialize, to the point where I only get the following code in Home.js:

`(function () {
"use strict";

// The initialize function must be run each time a new page is loaded.
Office.initialize = function (reason) {
    $(document).ready(function () {
        
        if (OfficeHelpers.Authenticator.isAuthDialog())
            return;

        var authenticator = new OfficeHelpers.Authenticator();
        authenticator.endpoints.registerAzureADAuth('##MYAPPID##', '##MYTENANT##');
        authenticator
            .authenticate(OfficeHelpers.DefaultEndpoints.AzureAD, true)
            .then(function(token) {
                console.log(token);
            })
            .catch(OfficeHelpers.Utilities.log);
    });
};

})();`

I know this appId and tenant work fine since I can get the same code to work with ADAL outside office JS, and already ironed out all reply urls and other issues,

The call to _openAuthDialog inside authenticator.authenticate never returns to the promise, and I experience the following error in JS console:

oauthdialog

The Auth popup does appear on top of Web Add-ins, but closes immediately after echoing this error,

Any ideas what is going wrong?

Second question: Am I correct to assume I can use this library for something else than MS Graph, such as Microsoft Dynamics 365 OData endpoint which supports OAuth 2.0 as well, or is this just for Office365 and MSGraph?

Thanks

@Rick-Kirkham
Copy link
Contributor

12002 means that either the URL that is passed to displayDialogAsync is not a valid URL or the Dialog window was redirected to an invalid URL. (See Dialog API for more.) Could you use the Fiddler tool to see what the actual URLs are?

@GregPartner
Copy link
Author

Thanks it works now,

I used the overrides to change the default redirectUrl and works fine now.
EndpointStorage.prototype.registerAzureADAuth = function (clientId, tenant, overrides)

I also changed the resource and was able to access my OData feed

Another question: Is there a method to logout to change credentials ?

@WrathOfZombies
Copy link
Contributor

@GregPartner There's no default logout implementation as it varies from provider to provider. However there's a logout endpoint for Azure AD that you can hit. You could write a simple method to hit that endpoint and it should log you out.

Also to your earlier question, we do support multiple oauth providers such as Facebook, Google, MSFT, Azure AD out of the box but you could very easily add any provider that works with standards compliant implicit OAuth.

If you do add an additional provider, please do consider sending in a pull request so that everyone can benefit from it.

@WrathOfZombies
Copy link
Contributor

WrathOfZombies commented Aug 29, 2017

@GregPartner Could you tell us what was wrong with the default redirectUrl. It points to location.origin and we'd like to understand what was wrong with that. If there's a bug we can fix it and if the error was misleading we can address the error message.

@GregPartner
Copy link
Author

I'm using this now:

var config = { clientId: clientId, baseUrl: "https://login.windows.net/" + tenant, resource: urlD365, redirectUrl: redirectUrl }; authenticator.endpoints.registerAzureADAuth(clientId, tenant, config);

When I comment the config.redirectUrl, I get the above error in the JS console.
Will send you contact details to profile email, you can contact me on Skype for Business and I'll show you?

@WrathOfZombies
Copy link
Contributor

Sure just search for bhkrish@microsoft.com on SFB and you can ping me there. Thanks 👍

@WrathOfZombies
Copy link
Contributor

@GregPartner I tried out the multi tenant access and you'd need to follow the steps listed here: #45 (comment)

The earlier method is a sub step that might be unnecessary.

@GregPartner
Copy link
Author

GregPartner commented Aug 30, 2017

Looks good on first tenant, I need to be able to logout with another user to test this though, so created new issue / question for logout #46 , Ta

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants