OfficeDev / microsoft-teams-library-js

JavaScript library for use by Microsoft Teams apps
https://docs.microsoft.com/microsoftteams/platform/
Other
425 stars 193 forks source link

getToken fails in authentication FrameContext #2107

Open vhensorskyi opened 8 months ago

vhensorskyi commented 8 months ago

Hi,

We have been using teams-js library 2.6.0 and noticed that await microsoftTeams.authentication.getAuthToken({ silent: true }) call fails with Cannot get authorization url App webApplicationInfo or resource not defined in manifest in microsoftTeams.FrameContexts.authentication but works fine in other contexts fine. Is it a known issue?

Regards, Volodymyr

AE-MS commented 8 months ago

Thanks for reporting this! I tried to repro the issue but was successfully able to call microsoftTeams.authentication.getAuthToken and get a token from within the pop-up authentication window (which had a frame context of authentication.)

I am able to see the place in the code where the "App webApplicationInfo or resource not defined in manifest" string is defined, but it doesn't seem like it should be triggered in this scenario.

Could you provide some more details so I can investigate further and help?

  1. Which host are you seeing this in? Outlook, Microsoft365 App, or Teams? If Teams, do you know if it's "New Teams" (aka V2) or "Legacy Teams" (aka V1)?
  2. What platform are you seeing this? Web/Windows/Mac/iOS/Android?
  3. I assume that your app manifest does actually define a resource in the webApplicationInfo section, but if you could confirm this, that would be great.
  4. I assume that your app is triggering an authentication pop-up by calling authentication.authenticate and then calling authentication.getAuthToken from within that pop-up window (based on your comment about the frame context being authentication. Is this correct? What parameters is it passing when it calls authentication.authenticate?
  5. Does calling getAuthToken from your app outside of an authentication pop-up (i.e. different frame context) work just fine?

Thanks!

vhensorskyi commented 8 months ago

Hello,

Thanks for your response.

  1. I checked on Teams both versions as well as on Web and Mac Desktop clients and the issue exists.
Screenshot 2024-01-03 at 09 33 10
  1. Web and Mac were used only

  2. Yes, webApplicationInfo is set properly in the manifest

  3. The is initiated from the card:

    { "type": "Action.Submit", "title": "Sign In", "data": { "msteams": { "type": "signin", "value": "${authUrl}" } } }

    and the popup has authentication context.

  4. Yes, using the same configuration getAuthToken fetches tokens fine in different contexts.

Let me know if any additional info is needed.

AE-MS commented 8 months ago

Thanks for the additional info. Triggering the authentication window from a card is likely the difference in how we are trying to reproduce the problem. Can you tell me more about how the card is being provided to Teams? E.g., is it being returned from a bot? Or a message extension?

vhensorskyi commented 8 months ago

Yes, it's an adaptive card shared by a bot in a personal conversation.

AE-MS commented 8 months ago

Thanks; with this information I was able to repro the problem. I will investigate and report back here.

vhensorskyi commented 7 months ago

Hi,

Is there any progress on this?

AE-MS commented 7 months ago

Thanks for checking in; I'm still working with the team responsible for the likely problematic code to identify the issue and understand their plan for the fix. I don't know of any workarounds, unfortunately.

vhensorskyi commented 7 months ago

Thanks for the info. Please keep me posted.

AE-MS commented 7 months ago

After reproducing the problem and debugging it based on your helpful information, it looks like the problem is in the Teams app itself (and not the application platform) so @nwojod-MSFT will transition the tracking of this issue to the folks who help with issues in Teams.

For reference for others: the issue only repros when the authentication pop-up is triggered from an adaptive card. It does not occur when the authentication pop-up is called from teamsjs using authentication.authenticate.

vhensorskyi commented 7 months ago

Thank you. FYI, it also reproducible from the messaging extension cards :(

Prasad-MSFT commented 7 months ago

@vhensorskyi - We have raised a bug for the same. We will inform you once we get any further update from engineering team. Thanks!

AE-MS commented 7 months ago

Hi @vhensorskyi -- I just wanted to give you an update: I talked with the developer in Teams responsible for the code with the issue and they've coded up a fix for this and it's out for code review. I'll provide more updates as I have them.

Prasad-MSFT commented 4 months ago

Hi @vhensorskyi - We got update from engineering team that the fix has been merged. Please do verify and let us know.

vhensorskyi commented 2 months ago

Hi @Prasad-MSFT,

Thanks for getting back. I've just tested the flow again and it doesn't seem to be working properly. Now instead of Cannot get authorization url App webApplicationInfo or resource not defined in manifest the function throws Error without any details. Please see a screenshot for reference. It was verified on web teams v2.

Screenshot 2024-06-13 at 11 04 01
handicraftsman commented 2 months ago

Hi @Prasad-MSFT ! Having the same issue, it is just Error: Error for us though.

It is failing in authentication context and in getAuthToken as well, as we can see in our Sentry dashboard.

Prasad-MSFT commented 2 months ago

Thanks for letting us know. We have informed the same to engineering team. Once we get any update, we will notify in this thread.