[英]Box API returned Error : : The remote server returned an error: (401) Unauthorized
i got the auth token using my api key den while trying to access user content i get this error 尝试访问用户内容时,我使用api密钥den获得了身份验证令牌,但出现此错误
The remote server returned an error: (401) Unauthorized.
Here is my c# code 这是我的C#代码
string url = "https://www.box.com/api/2.0/folders/0 \\ -H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
The -H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN"
is an argument of the example cURL command, not part of the API URL. -H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN"
是示例cURL命令的参数,而不是API URL的一部分。 It indicates an HTTP Header. 它指示HTTP标头。 You'll need to add that header to your
request
object. 您需要将该标头添加到您的
request
对象中。
Try this: 尝试这个:
string url = "https://www.box.com/api/2.0/folders/0";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("Authorization", "BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN");
Alternatively, you could try the Box C# SDK , which will take care of all that for you. 另外,您可以尝试Box C#SDK ,它将为您完成所有这些工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.