OfficeDev / teams-toolkit

Developer tools for building Teams apps
Other
454 stars 183 forks source link

Error in Microsoft Teams App on Outlook Mobile: Instantiating TeamsUserCredential Throws InternalError #10987

Open akanjimm opened 6 months ago

akanjimm commented 6 months ago

Describe the bug Our Microsoft Teams app works properly on all other hosts but throws an error on Outlook mobile.

The error occurs when instantiating the TeamsUserCrendential class and attempting to get the logged-in user's basic information (only on Outlook mobile).

To Reproduce Steps to reproduce the behavior:

  1. Scaffold a new sso enabled tab app (Teams, Outlook, Microsoft 365)
  2. Instantiate the TeamsUserCredential class and call the getUserInfo() or getToken("") method
// Example code using TeamsFx SDK version 2.3.0
const { loading, data, reload } = useData(async () => {        
    try {            
        const authConfig = {                
            clientId: process.env.REACT_APP_CLIENT_ID,                
            initiateLoginEndpoint: process.env.REACT_APP_START_LOGIN_PAGE_URL,            
        };            
        const credential = new TeamsUserCredential(authConfig);            
        const userData = await credential.getUserInfo();        
    } catch (err) {            
        // error handling        
}});
  1. Check out the app on Outlook mobile

Expected behavior For the app to be accessible across all hosts (desktop, web and mobile) and to get a logged-in user's basic data, without throwing error on outlook mobile

Screenshots Check out screenshot for error message on Outlook mobile and inability to get data from the Azure Functions backend MicrosoftTeams-image (2)

Test app on Microsoft 365 mobile MicrosoftTeams-image (3)

KennethBWSong commented 6 months ago

@akanjimm Thank you for reporting this issue. Would you please tell us which OS are you using (Android/iOS) and the version of Outlook app?

akanjimm commented 6 months ago

@KennethBWSong I'm using iOS and the version of the Outlook app is 4.2408.1

KennethBWSong commented 6 months ago

@akanjimm Thank you for your info. We are investigating this issue and will reach out to you as soon as we have any updates.

petr-istratov commented 5 months ago

Any updates in this? We're having same issue

KennethBWSong commented 5 months ago

Hi @petr-istratov We have upstream dependency on Outlook team for this issue and will update here if any progress.

KennethBWSong commented 4 months ago

Hi @akanjimm @petr-istratov Sorry for late reply. After debug with Outlook team, would you please try to add following lines in ./aad.manifest.json and see whether this can fix your issue?

{
  ...
  "preAuthorizedApplications": [
    ...
    {
      "appId": "27922004-5251-4030-b22d-91ecd9a37ea4",
      "permissionIds": [
        "${{AAD_APP_ACCESS_AS_USER_PERMISSION_ID}}"
      ]
    }
  ]
}
petr-istratov commented 4 months ago

@KennethBWSong Yes, thanks for the reply. This actually helps or it can be changed in App registration in Azure. Apart from this change you need to reconfigure environment variables in the backend. Update ALLOWED_APP_IDS and WEBSITE_AUTH_AAD_ACL

KennethBWSong commented 4 months ago

@petr-istratov Thanks for your info! We will also fix this issue in the TTK in the later release and update here when the fix is ready.