'Microsoft Teams SSO - Unable to Retrieve Token

I am trying to retrieve an SSO token in my Microsoft Teams task module for a logic am working on and when I use the Microsoft teams SDK I keep getting the error App resource defined in the manifest and iframe origin do not match

Does anyone have an idea of how to fix this?

In-app manifest, I have my resources defined as:

  "webApplicationInfo": {
    "id": "aedd2c2b-545f-4539-9437-8776",
    "resource": "api://subdomain.domain.com/aedd2c2b-545f-4539-9437-8776"
  },

In Azure, I have my scope defined in the app created in Azure Active Directory and this is the code below

                microsoftTeams.initialize()
                microsoftTeams.authentication.getAuthToken({
                    successCallback: (token: string) => {
                        this.setState({ token });
                        this._setAppContextFromMSTContext({ token });
                    },
                    failureCallback: (error) => {
                        this.showAuthenticationError();
                        logger.error(`Error getting token`, error);
                    },
                });

But I still can't fetch the token, I keep getting the error below, please let me know what else I am doing wrong

Error getting token



Solution 1:[1]

  • Please make sure that the resource specific permissions are granted consent to the application.Check if permissions to access teams are added in azure ad portal and granted consent .
  • And please recheck the resource parameter is correct by comparing the domaina and the client id in "resource": "api://{Your tab app domain}/{AAD App client id}"

References:

  1. understanding-azure-ad-single-sign-on-for-microsoft-teams-apps
  2. resource-specific-consent

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1