1
votes

After successful manifest upload, I am now struggling with getting the access token using Office JS API. I have followed the instructions but without luck so far.

The error I am getting is 13001 - the user is not signed in Office. However its clear that I am logged into Office 365 since I am running the add-in from Outlook Online.

Code:

function showDialog() {
    getDataWithToken({ forceConsent: false });


    Office.context.ui.displayDialogAsync('https://localhost:3000/PluginApp/index.html',
    { height: 80, width: 80, displayInIframe: true}, function(asyncResult) {
        // ... code
    });

    function getDataWithToken(options) {
        Office.context.auth.getAccessTokenAsync(options,
        function (result) {
            debugger;
            if (result.status === "succeeded") {
                //TODO1: Use the access token to get Microsoft Graph data.
            }
            else {
                handleClientSideErrors(result);
            }
        });
    }

    function handleClientSideErrors(result) {

        switch (result.error.code) {

            case 13001:
                getDataWithToken({ forceAddAccount: true });
                break;
        }
    }

print screen below:

enter image description here

Additional answers:

2) In my manifest file I have defined the ExecuteFunction to run the method when user clicked on addin. I am not using the taskpane since the width is too small. I would like to open a dialog to have more space to render the stuff. So therefore I cant get the info before the dialog is opened since I am getting possibly sensitive information so thats why the whole code is after opening of dialog.

3) My company uses primary Office 365 account. The setup is hybrid (on premise AD and cloud mailboxes. data is synced via DirSync).

2

2 Answers

1
votes

I don't know if this is a fix but I have pushed all checkboxes (in portal.azure.com -> Azure Active Directory -> Registrate apps -> myapp) desperately and I have got a different error now.enter image description here

0
votes
  1. Hmmmm. The product team reports that 13001 shouldn't ever be seen in Office Online. I'll try to confirm that.

  2. It looks like you are calling getAccessTokenAsync inside a method that is primarily intended to open a dialog. Can you clarify why? You don't need to create a dialog to use the API. You call the API from the task pane and if the user isn't signed in, Office itself will open a sign-in dialog.

  3. Also, Office Online can be accessed by a user signed in with a Microsoft Account, so the fact that you are using it doesn't ensure that you are logged into an Office 365 account. Are you using an Office 365 account or a MSA account?

  4. If you haven't already, take a look at: Troubleshoot SSO in Add-ins.