RestSharp Authenticator
To register a specific RestSharp credential, just create that type and assign the appropriate Authenticator.
CredentialStore.RegisterRefresh("ClientAPI", (o) => {
return new RestSharpCredentialStoreItem(
new RestSharp.Authenticators.JwtAuthenticator("MyToken"),
DateTimeOffset.UtcNow.AddMinutes(58));
});
Any time you create a client, simply assign this credential authenticator:
var rco = new RestClientOptions("https://localhost.com")
{
//Assign the CredentialAuthenticator with the name tied to the refresh
Authenticator = new CredentialAuthenticator("ClientAPI")
};
//Create a new client
using var client = new RestClient(rco);
//Anytime you execute any requests, it's automatically maintained.
Last updated