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

Add logging/ error statement for VS Code Credential for token expiration #18126

Closed
KarishmaGhiya opened this issue Oct 11, 2021 · 5 comments
Closed
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library.

Comments

@KarishmaGhiya
Copy link
Member

Reference - #17734 (comment)

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 11, 2021
@KarishmaGhiya KarishmaGhiya self-assigned this Oct 11, 2021
@KarishmaGhiya KarishmaGhiya added the Client This issue points to a problem in the data-plane of the library. label Oct 11, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 11, 2021
@KarishmaGhiya KarishmaGhiya added Azure.Identity needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Oct 11, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 11, 2021
@KarishmaGhiya KarishmaGhiya added this to the [2021] November milestone Oct 11, 2021
@KarishmaGhiya
Copy link
Member Author

KarishmaGhiya commented Feb 11, 2022

In this case we expect Msal to throw MsalInterationRequiredError/Exception.
So, whenever we get that, it means token is expired.
You can just mock out that exception from MSAL to simulate the error.

Maybe check if there are existing tests or add a test if not present

@sadasant
Copy link
Contributor

sadasant commented Mar 4, 2022

To test this, you can manually change the received token. You will receive it in one of the functions on src/client/identityCleint.ts. Something similar to this should work:

  async sendGetRequestAsync<T>(/* … */): Promise<NetworkResponse<T>> {
    // …
    let response = await this.sendRequest(request);
    response = changeResponseIfHasToken(response); // This line
    return {
      // …
    };
  }

  async sendPostRequestAsync<T>(/* … */): Promise<NetworkResponse<T>> {
    // …

    let response = await this.sendRequest(request);
    response = changeResponseIfHasToken(response); // This one
    return {
      // …
    };
  }
}

// Something like this…
function changeResponseIfHasToken(response) {
  if (response.indexOf("token") > -1) {
    const token = JSON.parse(response).token; // it might be called acces_token
    const tomorrow = new Date();
    tomorrow.setTime(tomorrow.geetTime()+1);
    return JSON.stringify({ token, expiresOn: tomorrow })
  }
  return response;
}

We can sync up in case something is off 🙂 ✨team work✨

@KarishmaGhiya
Copy link
Member Author

I am positive that the approach above will help us debug the scenario of timeout and evaluate if we get appropriate error message in that scenario. But for now this credential is broken because of this bug. Due to this, when we try to run the application using the credential, we will first run into the issue described in the bug and not be able to test the timeout scenario. We can wait until bug is fixed.

@KarishmaGhiya KarishmaGhiya modified the milestones: [2022] April, Backlog Mar 24, 2022
@sadasant
Copy link
Contributor

Thank you, @KarishmaGhiya

Copy link

Hi @KarishmaGhiya, we deeply appreciate your input into this project. Regrettably, this issue has remained inactive for over 2 years, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2024
@xirzec xirzec removed this from the Backlog milestone May 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

No branches or pull requests

4 participants