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 overload of GetTokenAsync with an exception out param #196

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

asklar
Copy link

@asklar asklar commented Aug 15, 2022

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

The WCT MsalProvider doesn't expose exceptions returned from the MSAL library. You can see that a token returned is null, but the information about what went wrong is lost.

What is the new behavior?

New overload (since the previous methods come from a base class and didn't want to touch that), for GetTokenAsync that can return out the exception that we encountered.

PR Checklist

  • Tested code with current supported SDKs
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@ghost
Copy link

ghost commented Aug 15, 2022

Thanks asklar for opening a Pull Request! The reviewers will test the PR and highlight if there is any merge conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@michael-hawker michael-hawker added this to the 8.0.0 milestone Aug 24, 2022
@michael-hawker michael-hawker modified the milestones: 8.0.0, 7.1.3 Dec 14, 2022
@michael-hawker
Copy link
Member

michael-hawker commented Dec 15, 2022

Thanks @asklar,

I'm not sure how a non-default out parameter for a method works after a parameter with a default value @Sergio0694?

Since the method is protected, this will break someone if they've inherited from this class, eh?

protected async Task<string> GetTokenWithScopesAsync(string[] scopes, bool silentOnly = false, out Exception exception)

And since the exception is now re-thrown, even though it wasn't good that we ate the exception, it does mean the code would now cause a consuming application to crash instead now.

ExceptionDispatchInfo.Capture(exception).Throw();

Think we may want to just make a larger breaking change here to clean this up in the future?

@Richasy what are your thoughts as well? Think we'll skip this one for the 7.1.3 patch?

@michael-hawker michael-hawker modified the milestones: 7.1.3, 8.0.0 Dec 15, 2022
@michael-hawker
Copy link
Member

This also ties into #180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants