如何在Asp.Net中使用Google Drive SDK检索文档

时间:2012-11-29 15:18:02

标签: asp.net google-drive-api

我正在开发一个使用ASP.NET检索Google云端硬盘文档列表的项目,但我收到了错误消息:

  

发生错误:Google.Apis.Requests.RequestError每日限制   未经验证的使用超出。继续使用需要注册。 [403]

这是我的网站(此链接收到错误):http://www.netdesklive.com/

我正在尝试DrEdit代码,但没有正常工作。

我按照https://developers.google.com/drive/examples/dotnet设置了所有凭据,但仍然出现错误

所以请,建议我

代码:

- >我在状态和代码中获得空值

public ActionResult Index(string state, string code)
{
    try
    {
        IAuthenticator authenticator = Utils.GetCredentials(code, state);
        // Store the authenticator and the authorized service in session
        Session["authenticator"] = authenticator;
        Session["service"] = Utils.BuildService(authenticator);
    }
    catch (CodeExchangeException)
    {
        if (Session["service"] == null || Session["authenticator"] == null)
        {
            Response.Redirect(Utils.GetAuthorizationUrl("", state));
        }
    }
    catch (NoRefreshTokenException e)
    {
        Response.Redirect(e.AuthorizationUrl);
    }

    DriveState driveState = new DriveState();

    if (!string.IsNullOrEmpty(state))
    {
        JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
        driveState = jsonSerializer.Deserialize<DriveState>(state);
    }

    if (driveState.action == "open")
    {
        return OpenWith(driveState);
    }
    else
    {
        return CreateNew(driveState);
    }
}

1 个答案:

答案 0 :(得分:0)

您的错误消息表明您的请求未获得授权。您应该使用Oauth2授权它们: