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

时间:2022-11-21 15:49:40

I am working on a project that retrieve Google Drive docs list using ASP.NET, but I'm getting an error:

我正在开发一个使用ASP.NET检索Google Drive文档列表的项目,但是我收到一个错误:

An error occurred: Google.Apis.Requests.RequestError Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup. [403]

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

This is my site (getting error on this link) : http://www.netdesklive.com/

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

I am trying DrEdit code for this, but not working proper.

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

I set all the credential as per https://developers.google.com/drive/examples/dotnet but still i m getting an error

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

So Please, Suggest me

所以,请建议我

Code :

-> I am getting null value in state and code

- >我在状态和代码中得到null值

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 个解决方案

#1


0  

Your error message suggests that your requests are not authorized. You should authorize them using Oauth2 :

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

#1


0  

Your error message suggests that your requests are not authorized. You should authorize them using Oauth2 :

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