Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TeamsUserCredential - Unable to get a token for a specific scope #12321

Open
schnito opened this issue Sep 2, 2024 · 2 comments
Open

TeamsUserCredential - Unable to get a token for a specific scope #12321

schnito opened this issue Sep 2, 2024 · 2 comments
Assignees
Labels

Comments

@schnito
Copy link

schnito commented Sep 2, 2024

Describe the bug
Calling TeamsUserCredential getToken with a scope as parameter generates the error "Error - Failed to get access token cache silently, please login first: you need login first before get access token.".
It works well if we specify empty string: getToken("")

To Reproduce
Steps to reproduce the behavior:

  1. Create new Tab app with React
  2. Follow the guide to configure SSO https://learn.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/authentication/tab-sso-overview
  3. In Tab.tsx, add the following code to get a token
    const { teamsUserCredential } = useContext(TeamsFxContext);
    const { loading, data, error } = useData(async () => {
    if (teamsUserCredential) {
    const userInfo = await teamsUserCredential.getUserInfo();
    const token = await teamsUserCredential.getToken(["access_as_user"]);
    return token;
    }
    });
  4. Run the application, login with your accont. Open developer console and see the error

Expected behavior
A token should by returned for a specific scope

Screenshots

image
image

VS Code Extension Information (please complete the following information):

  • Version 5.8.1
Copy link
Contributor

Thank you for contacting us! Any issue or feedback from you is quite important to us. We will do our best to fully respond to your issue as soon as possible. Sometimes additional investigations may be needed, we will usually get back to you within 2 days by adding comments to this issue. Please stay tuned.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Sep 2, 2024
@adashen adashen added investigating TA:E2E Team Area: E2E labels Sep 3, 2024
@yiqing-zhao
Copy link
Contributor

Hi @schnito, thanks for your post. I’m currently investigating the issue and will update you as soon as possible.

@adashen adashen removed the needs attention This issue needs the attention of a contributor. label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants