RestClient Authenticator is now obsolete

922 views
Skip to first unread message

logan

unread,
Apr 27, 2023, 12:57:42 PM4/27/23
to RestSharp
I updated to the latest version of RestSharp in C# VS and I can no longer authenticate using bearer token and RestClient.Authenticator. It would seem the page is outdated as well as all the code on the page using "Client.Authenticator"

error:
CS0618: 'RestClient:Authenticator' is obsolete: Use RestClientOptions.Authenticator instead

I looked into RestClientOptions but the documentation doesn't show how to use Bearer Token.  - https://restsharp.dev/v107/#restclient-and-options

Searching online I found a solution that did solve my problem.
var client = new RestClient("link_here");
client.AddDefaultHeader("Authorization", string.Format("Bearer {0}", bearerToken)); 

Regards








Reply all
Reply to author
Forward
0 new messages