In Python I can successfully make a request (with authorization passing) by doing:
def send_request(self, url, public_key, secret_key):
session = requests.session()
session.auth = (public_key, secret_key)
return session.get(url)
I'm trying to replicate this in C# but it's not authorizing:
RestClient client = new RestClient(url);
RestRequest request = new RestRequest(url_stuff, Method.GET);
request.AddHeader(public_key, secret_key);
return client.Execute(request).Content;
What am I missing here?
session.auth = (public_key, secret_key)
in python is shorthand for Basic authentication, with public_key
being user name and secret_key
a password. To do the same with RestClient
you need to:
RestClient client = new RestClient(url);
client.Authenticator = new HttpBasicAuthenticator(public_key, secret_key);
return client.Execute(request).Content;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.