OfficeDev/office-js

NAA: Unable to initialize MSAL on Outlook for Windows in an Event handler

Closed this issue ยท 10 comments

An exception is thrown when initializing the MSAL library:

[BrowserAuthError: crypto_nonexistent: The crypto object or function is not available.]
  errorCode: 'crypto_nonexistent',
  errorMessage: 'The crypto object or function is not available.',
  subError: '',
  name: 'BrowserAuthError'

Your Environment

  • Platform: PC desktop
  • Host: Outlook
  • Office version number: Beta Channel Version 2406 Build 17630
  • Operating System: Windows

Expected behavior

The initialization and authenticating using NAA should be successful when running in an Event-based Activation scenario.

Current behavior

An exception occurs.

Steps to reproduce

  1. Create an Outlook app with an LaunchEvent handler registered with the OnNewMessageCompose event.
  2. Initialize NAA according to the documentation: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/enable-nested-app-authentication-in-your-add-in#initialize-the-public-client-application
  3. Wrap the code in try/catch and log any errors
  4. Run Outlook and create a new email
  5. Use Runtime Logging to observe the exception:
[BrowserAuthError: crypto_nonexistent: The crypto object or function is not available.]
  errorCode: 'crypto_nonexistent',
  errorMessage: 'The crypto object or function is not available.',
  subError: '',
  name: 'BrowserAuthError'

Context

We want to move our add-in over to the new auth model.

Useful logs

window.nestedAppAuthBridge is undefined in this context. It is defined when running our add-in in the Taskpane.

Support for NAA in Event Based Add-ins is not enabled yet. This feature is coming, but there is not a timeline to share right now.

Internal Ref #: 8774618

Assigning to mattgeim for documentation once this is enabled.

@timwan10 @mattgeim Will it be available when legacy Exchange callback tokens will be turned off in October 2024? Our event-based add-in is using the Outlook REST API.

Screenshot from the last community call regarding NAA and event-based add-ins:
image

Support for NAA in Event Based Add-ins is not enabled yet. This feature is coming, but there is not a timeline to share right now.

Internal Ref #: 8774618

@timwan10 do we have a timeline yet? Thanks!

@fedeisas - event based add-ins should be testable in preview in the Beta channel now.

How can we be getting this close to a deprecation of Exchange Web Service token usage and all of this is not yet available in GA for us to be developing and testing against on all platforms?

@mattgeim I would just like to confirm that NAA-SSO is now usable in Event-based addins? How about NAA-SSO on spam addins? Thanks.

@glr0221 I tried event-based addins with NAA on Windows and Mac, but I still have some issues. Maybe it's interesting for you as well #4764

Thanks @manuelsidler . Tracking that ticket as well. Thanks again.