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

Would be nice if there would be a possibility to replace the Authenticator after creating the Client #2101

Open
fseidl-bauradar opened this issue Jun 14, 2023 · 6 comments

Comments

@fseidl-bauradar
Copy link
Contributor

As already requested by

#1015

it would be a nice Feature if RestSharp Handles the JWT Access- and RefreshToken.
In the current Implementation, a Authenticator Implementation is not able to Refresh the JWTTokenPair,
if the AccessToken is going to exceed runtime.
Because to Refresh The Token Pair, the Authenticator would need a to perform a RestRequest to the Server and therefor a RestClient.
But neither the DI neither a user can provide the RestClient, because to Construct a RestClient, we need to set the Authenticator.
This leads to a Circular Dependency, which is not solveable.

A possibility would be to Create another RestClient, for the Authenticator, but I don't think this would be a clean solution to the problem.
Another solution is to use the Interceptor Pattern Implementation, as provided in the PullRequest, bellow, because the Interceptors are provided inside a List, they can be changed even after the RestClient have been created.
As I think the Authenticator is a special form of the Interceptor Pattern, therefor this solution fits in mine optionion.
Additionally, I would say it's not unusual to allow adding Interceptors at any time.

#2076

@LukeFranky
Copy link

100% agree. This used to be possible, but was deprecated for some reason and now I have bunch of refactoring to do. Frustrating!

@bbuehrer
Copy link

bbuehrer commented Sep 5, 2023

Is there anything new on the subject?
I also need to be able to change the authenticator after creating the RestClient.

@fseidl-bauradar
Copy link
Contributor Author

Sorry, currently I am waiting, seems like the maintainer is little bit busy

@abc123xxx
Copy link

Is there anything new on the subject?
I also need to be able to change the authenticator after creating the RestClient.

@rassilon
Copy link

rassilon commented Mar 14, 2024

@LukeFranky , @bbuehrer , @fseidl-bauradar, I mentioned in another issue recently that RestRequest has an Authenticator property that you can use on requests that require a different authentication mechanism than the default.

The reason that the property is now read-only is for thread safety reasons.

@abc123xxx
Copy link

Yes, that is the solution

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

No branches or pull requests

5 participants