【发布时间】:2017-03-16 13:47:07
【问题描述】:
我正在使用以下代码通过 Google .Net 客户端库向 Google 进行身份验证。
public static void auth()
{
string clientId = "xxxxxx.apps.googleusercontent.com";
string clientSecret = "xxxxx";
string[] scopes = new string[] { "https://www.googleapis.com/auth/contacts.readonly" }; // view your basic profile info.
try
{
// Use the current Google .net client library to get the Oauth2 stuff.
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
, scopes
, "test"
, CancellationToken.None
, new FileDataStore("test")).Result;
// Translate the Oauth permissions to something the old client libray can read
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.AccessToken = credential.Token.AccessToken;
parameters.RefreshToken = credential.Token.RefreshToken;
RunContactsSample(parameters);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
我正在使用我自己的客户端 ID 和客户端密钥。 当我从 Visual Studio 运行时,此代码完美运行,但在 IIS 中托管后无法运行。
我提到在 google api 控制台中重定向的 URI 是 http://localhost/authorize/
我的 IIS 主机 URL 是 http://localhost/googleintegration.aspx
我在上个月遇到了这个问题,任何人都可以为此提供解决方案..
【问题讨论】:
-
您遇到了什么错误? IIS 是否有权写入 %appdata%?
-
是的,我为每个用户授予了对 %appdata% 的完全访问权限。我得到“请求超时错误”。
-
我只想运行 localhost 本身,我的托管 url 是 'localhost/googleintegration.aspx',我从以下页面 'daimto.com/google-contacts-with-c' 获得了这个参考代码
-
联系我daimto.com/contact 如果你能帮我把它部署到 IIS 我会看看我能不能调试这个库。
标签: c# asp.net iis google-oauth google-contacts-api