C# 发送授权的正确方式是什么';代币';使用RestSharp

C# 发送授权的正确方式是什么';代币';使用RestSharp,c#,.net,authorization,restsharp,C#,.net,Authorization,Restsharp,我们构建了一个API,它正在等待来自一些客户端软件的调用。我们使用Python获取(ting)和发布(ting)没有问题,但是我们有人试图使用基于RESTSharp库的一些.Net代码访问它,尽管搜索了很多小时,但他们似乎无法获得授权 下面是一些有效的Python代码 POST_HEADER = {'Authorization': "Token a_valid_token_that_works_with_python code", 'Content-Type':'applicati

我们构建了一个API,它正在等待来自一些客户端软件的调用。我们使用Python获取(ting)和发布(ting)没有问题,但是我们有人试图使用基于RESTSharp库的一些.Net代码访问它,尽管搜索了很多小时,但他们似乎无法获得授权

下面是一些有效的Python代码

POST_HEADER = {'Authorization': "Token a_valid_token_that_works_with_python code",
       'Content-Type':'application/json'} 
BASE_URL = 'https://api.ourendpoint.com/v1/user-tasks/'
#here is the code to POST some data - the authorization token is in POST_HEADER
response = requests.post(BASE_URL, data = JSON_STRING ,headers = POST_HEADER)
这很好-但是我们认为类似的.Net代码不起作用-我们得到了一个授权错误-所以令牌的发送方式有问题

RestClient client = new RestClient("https://api.ourendpoint.com/v1/");
client.AddDefaultHeader("Authorization", "Token  a_valid_token_that_works_with_python code");

RestRequest request = new RestRequest("user-tasks", Method.POST);

IRestResponse response = client.Execute(request);

# there is some stuff here to create the data to be POST (ed) but we have
# taken that out so we could focus on just getting authorization

var obj = JObject.Parse(response.Content);
我们的服务器对POST的尝试做出以下响应

    b'{"detail":"Authentication credentials were not provided."}
也许更有趣的是,当我们查看服务器日志时,我们看到服务器正在将POST尝试作为GET读取

January 29th 2018, 14:23:39.633API request with method: GET, URI: /v1/user-tasks/  b''  b'{"detail":"Authentication credentials were not provided."}'    GET