尝试使用Google表格API,GoogleWebAuthorizationBroker.AuthorizeAsync()会出现“System.AggregateException”错误

时间:2017-03-24 23:42:28

标签: c# google-sheets-api

我正在尝试按照Google表格.NET API here的快速入门教程进行操作。

但是当它到达这一行时:

            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                Scopes,
                "user",
                CancellationToken.None,
                new FileDataStore(credPath, true)).Result;

以下是发生的事情:

  1. Internet Explorer打开。

  2. 转到accounts.google.com应用程序授权窗口。

  3. 点击Allow

  4. 重定向到localhost。在IE中获取此消息。

  5. This page can't be displayed
    
    * Make sure the web address http://localhost:54538 is correct.
    * Look for the page with your search engine.
    * Refresh the page in a few minutes.
    
    1. 在VS Express中,抛出此异常:
    2. An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll
      
      Additional information: One or more errors occurred.
      

      有可能存在阻止我访问此localhost端口的企业IT安全策略;我尝试直接在Chrome地址栏中输入“localhost”和“127.0.0.1”,并且在两种情况下都出现了“无法访问此网站”错误。

      编辑:我的client_id.json文件如下:

      {"installed":{"client_id":"[long ID string].apps.googleusercontent.com","project_id":"angular-polygon-162522","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"[secret ID]","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}
      

0 个答案:

没有答案