OfficeDev / microsoft-teams-library-js

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

V2.9.1 - getAuthToken => Error: Definition not found #1638

Open ayblanchet opened 1 year ago

ayblanchet commented 1 year ago

Context

Usage

       microsoftTeams.app.initialize().then(()=>{
            var token = microsoftTeams.authentication.getAuthToken({"silent":true});
        });

Issue

microsoftTeams.authentication.getAuthToken returns an error message "Definition not found" in desktop.

WorkArounds

I tried to use like this : https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/app-auth/nodejs/src/views/tab/simple It's works in desktop version but in browser version the /simple-start popup not close automatically when /simple-end process is terminate.

ghost commented 1 year ago

Hi ayblanchet! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

Meghana-MSFT commented 1 year ago

Thank you for reporting this issue, we will look into this issue and get back to you.

nwojod-MSFT commented 1 year ago

@ayblanchet can you try awaiting the call using this syntax

microsoftTeams.authentication.getAuthToken({"silent": true}).then((token) => { console.log("myToken: " + token) });?

Also, what Teams clients are you using and how are you running your app in Teams? Is this a meetings or channels app? Kindly provide these to help use investigate. Thanks

ayblanchet commented 1 year ago

@nwojod-MSFT same error when using your syntax: authentication.ts:232 Uncaught (in promise) Error: Definition not found I'm use Teams Desktop Microsoft Teams 1.6.00.6588 (32 bits) same behaviour with Teams online. I'm using this for a connector in channels. Thank you for your help,

nwojod-MSFT commented 1 year ago

Thanks for the information. We will keep investigating and get back to you.

erinha commented 1 year ago

Hi @ayblanchet, thanks for the info you provided! I'm sorry you're running into this issue. I'd like to get a bit more understanding of how your app is invoked before the call to microsoftTeams.authentication.getAuthToken is made and fails.

Are you invoking the getAuthToken API call in the connector configuration page (as described here: Create connectors for Microsoft 365 Groups - Teams | Microsoft Learn) or are you invoking it after launching your app by clicking an action button on the connector-generated adaptive card present in your channel (for example, clicking "View Task Details" button as shown in #15 in the "Build Teams connectors" tutorial step 5: https://learn.microsoft.com/en-us/microsoftteams/platform/sbs-teams-connectors?tutorial-step=5)?

If neither applies, can you please share more information about how your app running teams-js is invoked?

ayblanchet commented 1 year ago

Hi Erinha,

Yes, I followed these 2 tutorials. To deploy, I have try to use "upload a custom app" with teams, and deploy an app with portal admin teams website. $(document).ready(async function () { microsoftTeams.app.initialize().then(()=>{ microsoftTeams.authentication.getAuthToken({"silent": true}).then((token) => { console.log("myToken: " + token) }); }); });

Best regards,

Meghana-MSFT commented 1 year ago

Apologies for the delay in response. We checked this with following sample -https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/connector-todo-notification/nodejs.

It is giving Error: Definition not found at getAuthToken. We will check this internally and get back to you. Thank you for your patience.

Meghana-MSFT commented 1 year ago

@ayblanchet - We checked internally and got the below response,

The SSO flow (i.e. getAuthToken API) for Connectors is not supported. This flow is only supported for bots and tabs. As per our Connector documentation here: https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-creating

The only supported mechanism for authentication in Connectors is the popup auth flow documented here: https://learn.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/authentication/auth-flow-tab

That is also what our Connector samples demonstrate.

ayblanchet commented 1 year ago

Hello, @Meghana-MSFT I have use this too with this tuto: https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/app-auth/nodejs/src/views/tab/simple, it's works in desktop version but in browser version the /simple-start popup not close automatically when /simple-end process is terminate (When notifysuccess is called) .

Vaibhav-MSFT commented 1 month ago

Hello @ayblanchet , Can you please let us know that if you are still facing this issue?