在获得具有所需权限的身份验证令牌后,我正在尝试访问用户的任务。
请求网址:
https://www.googleapis.com/tasks/v1/lists/%40default/tasks?key={YOUR_API_KEY}
提出请求的代码:
public void FetchTasks(string url)
{
var httpWebRequest = HttpWebRequest.CreateHttp(url);
httpWebRequest.BeginGetResponse(new AsyncCallback(FinishedWebRequest), httpWebRequest);
}
private void FinishedWebRequest(IAsyncResult ar)
{
var httpWebRequest = ar.AsyncState as HttpWebRequest;
var httpWebResponse = (HttpWebResponse) httpWebRequest.EndGetResponse(ar);
byte[] responseByteArray= new byte[200];
httpWebResponse.GetResponseStream().Read(responseByteArray, 0, responseByteArray.Length);
}
回复
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
我是否需要其他任何内容作为请求标头的一部分以及 URL 中的身份验证令牌?