Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs
Dear @Kuldeep Ravaliya
I understand you are looking to clarify why the Bot Framework Token Service defaults to the 6-digit magic code flow during LinkedIn OAuth authentication in Microsoft Teams, and whether automatic token exchange can be forced.
Question: Why Token Service Falls Back to the 6-Digit Magic Code
The 6-digit magic code is a fallback security mechanism used by the Bot Framework Token Service to prevent token hijacking. It occurs whenever the Token Service cannot securely verify that the user who completed the browser login is the same user active in the Teams chat session.
In your setup, this occurs due to three specific conditions:
- Provider Limitations (Generic OAuth2 vs. Entra ID): Automatic background token exchange (silent SSO via signin/tokenExchange) is natively supported only for Microsoft Entra ID (Azure AD v2). Third-party Generic OAuth2 providers (such as LinkedIn) require an explicit interactive login and consent dialog.
- Custom Sign-in Launch via getSignInResource(): Generating a raw URL via getSignInResource() and opening it through a generic link action bypasses the built-in Teams authentication callback. Because the popup window cannot communicate its success callback back to the Teams client context, the Token Service renders the 6-digit code as a security gate.
- Missing Popup Close Callback: If the OAuth completion redirect does not trigger microsoftTeams.authentication.notifySuccess(), Teams cannot capture the authorization state directly, forcing the manual code entry page.
Question: Can You Force Automatic Token Exchange?
- Silent SSO: No. You cannot perform silent, zero-click token exchange for 3rd-party OAuth2 providers like LinkedIn because the OAuth protocol requires external identity provider consent.
- Eliminating the 6-Digit Code: No. There is no supported way to force the automatic path when the identity/conversation correlation fails. Silent SSO is only fully supported for Microsoft Entra ID.
Please let me know if you need further assistance.