【发布时间】:2017-03-13 17:45:06
【问题描述】:
我正在尝试使用 ASPSnippets.GoogleAP.dll 和 Google.Apis.Drive.v3.dll 从 Google 云端硬盘下载文件。但面临一些挑战。正在下载文件,但它包含某种奇怪的 HTML 内容。
我正在使用以下代码下载它:
GoogleConnect.ClientId = "xxxx.apps.googleusercontent.com";
GoogleConnect.ClientSecret = "xxxxxx";
GoogleConnect.RedirectUri = Request.Url.AbsoluteUri.Split('?')[0];
GoogleConnect.API = EnumAPI.Drive;
if (!string.IsNullOrEmpty(Request.QueryString["code"]))
{
string code = Request.QueryString["code"];
string json = GoogleConnect.Fetch("me", code);
GoogleDriveFiles files = new JavaScriptSerializer().Deserialize<GoogleDriveFiles>(json);
//Remove the deleted files.
var driveService = new DriveService();
Label1.Text = theHiddenField1.Value;
WebClient wb = new WebClient();
wb.DownloadFile(theHiddenField1.Value, "C://" + fileName);
}
else if (Request.QueryString["error"] == "access_denied")
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
}
else
{
GoogleConnect.Authorize("https://www.googleapis.com/auth/drive.readonly");
}
有人可以帮我解决这个问题吗?
【问题讨论】:
-
您可以发布您收到的错误消息吗?还是您没有收到错误,只是没有下载?
-
@Jay266 我没有收到任何错误消息文件正在下载 soem html 内容。
-
那么 html 是怎么说的?
-
@AlexK。当我在浏览器页面中打开 html 时,它是 gmail 登录页面。
标签: c# google-drive-api google-developers-console google-developer-tools