Office-Add-in-samples icon indicating copy to clipboard operation
Office-Add-in-samples copied to clipboard

Error thrown in AttachmentDemo for Outlook SSO sample

Open Stephen-C-Butler opened this issue 4 years ago • 4 comments

Question

Regarding: PnP-OfficeAddins/Samples/auth/Outlook-Add-in-SSO/

When I run the sample code inside an Outlook desktop client, select a message with an attachment, and click "Choose Attachments" it throws this error:

JavaScript critical error at line 150, column 11 in https://localhost:44355/Scripts/MessageRead.js\n\nSCRIPT1004: Expected ';'

That refers to the top line here from MessageRead.js (Column 11 is the word "function"):

async function saveAttachments(attachmentIds, options) {
    //Set default SSO options if they are not provided
    if (options === undefined) options = { allowSignInPrompt: true, allowConsentPrompt: true, forMSGraphAccess: true };
    
    showSpinner();

    // Attempt to get an SSO token
    try {
        let bootstrapToken = await OfficeRuntime.auth.getAccessToken(options);

        // The /api/saveAttachmentsUsingToken controller will make the token exchange and use the 
        // access token it gets back to make the call to MS Graph.
        // Server-side errors are caught in the .fail block of saveAttachmentsUsingToken.
        saveAttachmentsUsingToken("/api/saveAttachments", bootstrapToken, attachmentIds);
    }
    catch (exception) {
        // The only exceptions caught here are exceptions in your code in the try block
        // and errors returned from the call of `getAccessToken` above.
        if (exception.code) {
            handleClientSideErrors(exception);
        }
        else {
            showNotification("EXCEPTION: ", JSON.stringify(exception));
        }
    }

Any ideas?

Stephen-C-Butler avatar Jun 18 '21 16:06 Stephen-C-Butler

Thanks for reporting this @Stephen-C-Butler.

@Rick-Kirkham, could you please take a look?

AlexJerabek avatar Jun 18 '21 17:06 AlexJerabek

I am not a Java coder. So, noob alert.

My own research is making me suspect that I am using a browser which does not support the async/await functionality. I am reading that this was introduced in JScript 1.7.

I go to this link using the machine/browser on my tools box. http://jsfiddle.net/Ac6CT/ That tool tells me I am using version 1.7, but I also read that Microsoft has a version of JScript which does not implement all functionality.

If it helps, I'm using this browser: Microsoft Edge Version 91.0.864.53 (Official build) (64-bit)

Stephen-C-Butler avatar Jun 18 '21 17:06 Stephen-C-Butler

Hi @Stephen-C-Butler,

Thanks for catching this! The sample needs a polyfill added so it can work for ES5 on older browsers. I put this on the backlog to fix the sample.

davidchesnut avatar Jul 20 '21 00:07 davidchesnut

Hmm …

The most current version of Microsoft Edge is an “older browser”?

From: David Chesnut @.> Sent: Monday, July 19, 2021 7:18 PM To: OfficeDev/PnP-OfficeAddins @.> Cc: Butler, Stephen C. @.>; Mention @.> Subject: [External] Re: [OfficeDev/PnP-OfficeAddins] Error thrown in AttachmentDemo for Outlook SSO sample (#175)

This message is from an EXTERNAL SENDER - be CAUTIOUS, particularly with links and attachments.


Hi @Stephen-C-Butlerhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Stephen-2DC-2DButler&d=DwMCaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=BwtBXun5VOztfEFwsGzqAmpxfRCZeZtK6R3dZph3QtE&m=-S7XG0JgK9s4XOaz1JZINQpmjABRflwHY1EdnNgyeS8&s=PH4XevD-0kUjdMW-dihOjU4yLruQ-M8_JxOGG-lLayY&e=,

Thanks for catching this! The sample needs a polyfill added so it can work for ES5 on older browsers. I put this on the backlog to fix the sample.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_OfficeDev_PnP-2DOfficeAddins_issues_175-23issuecomment-2D882948181&d=DwMCaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=BwtBXun5VOztfEFwsGzqAmpxfRCZeZtK6R3dZph3QtE&m=-S7XG0JgK9s4XOaz1JZINQpmjABRflwHY1EdnNgyeS8&s=Om4w3NS915LZOq25neSGt1oIannawL8PbSmmkui9_Ks&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AQ5P7L7LVX5JWE7NTP5XQBLTYS6CJANCNFSM4657QLGQ&d=DwMCaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=BwtBXun5VOztfEFwsGzqAmpxfRCZeZtK6R3dZph3QtE&m=-S7XG0JgK9s4XOaz1JZINQpmjABRflwHY1EdnNgyeS8&s=FaoihJXSSpAk-l5Vr2XPdA4Csu82N5__dxEka8PIFBI&e=.


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. Your privacy is important to us. Accenture uses your personal data only in compliance with data protection laws. For further information on how Accenture processes your personal data, please see our privacy statement at https://www.accenture.com/us-en/privacy-policy.


www.accenture.com

Stephen-C-Butler avatar Jul 20 '21 11:07 Stephen-C-Butler

Hi @Stephen-C-Butler, hoping to close out this old issue. I think the original issue identified here is fixed. There was a big refresh on this sample a while ago. So if it is still happening can you please reopen this?

When I referred to older browsers, I should have been more specific. On some older versions of Office on Windows, the IE 11 webview is used. If you plan to run on those older versions you would need to transpile the code to support ES5. There's more info in Browsers used by Office Add-ins.

Hope this helps, and please reopen if there is still any issue with this sample. Thanks! David

davidchesnut avatar Mar 23 '23 22:03 davidchesnut