-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Call an authenticate method before retrying #122
Comments
Hey @robertbaker. This came up on StackOverflow recently, but I think the q has been deleted. It's very possible. Configure a policy with an The code at the top of #107 gives an example. [#107 uncovered an obscure compiler gotcha that led to an async sequencing issue, now fixed, but the code example matches your need I think!] Let us know if you need any further assistance! EDIT: The example in #107 is async, but you can also do this with sync policies. |
@robertbaker If an additional issue is that We are looking at allowing Policies to handle return values as well as exceptions natively - see #14, and wider discussion in the Roadmap. Any feedback you have towards this feature would be welcome! Thanks. UPDATE: The feature #14 is now delivered. The main Polly readme describes much more elegant ways of handling exceptions and |
Thanks, I'll try to implement this soon. |
@robertbaker No problem. @PhilipAnthonyMurray was essentially working on sthg similar I think. We are doing the same thing in-house and achieved this pattern (refreshing authentication on retry) against both straight https authentication and SAML authentication: but the pattern isn't any more complicated than outlined above. |
@adamhathcock You raised OAuth and Polly on #90, see this thread #122. One pattern is to use the var authorisationEnsuringPolicy = Policy
.Handle<AuthorizationException>()
.Retry(1, onRetry: (e, i) => RefreshAuthorization());
authorisationEnsuringPolicy.Execute(() => DoSomethingThatRequiresAuthorization()); |
Thanks @reisenberger I was sure there was some way to do it without having to bring in some kind of new concept. |
Closing historic issue. Fully documented on wiki |
@robertbaker asked under a separate issue (moving here as worth calling out as own issue!)
The text was updated successfully, but these errors were encountered: