我正在尝试按照Google表格.NET API here的快速入门教程进行操作。
但是当它到达这一行时:
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
以下是发生的事情:
Internet Explorer打开。
转到accounts.google.com
应用程序授权窗口。
点击Allow
。
重定向到localhost
。在IE中获取此消息。
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.
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"]}}