0

我正在构建一个应用程序来通过谷歌分析获取数据。为此,我从 Google API 控制台创建了一个服务帐户信息,并在我的 .NET webform 应用程序中成功地通过以下代码获取数据:

string clientEmailId = ConfigurationManager.AppSettings.Get("clientEmailId");
string keyFile = AnalyticsKeyFileInitialPath + ConfigurationManager.AppSettings.Get("keyFile");
string keyPass = ConfigurationManager.AppSettings.Get("keyPass");
var desc = GoogleAuthenticationServer.Description;
var key = new X509Certificate2(keyFile, keyPass, X509KeyStorageFlags.Exportable);
var client = new AssertionFlowClient(desc, key) { ServiceAccountId = clientEmailId, Scope = scopeUrl };
var auth = new OAuth2Authenticator<AssertionFlowClient>(client, AssertionFlowClient.GetState);
var gas = new AnalyticsService(new BaseClientService.Initializer
{
    Authenticator = auth
});
//auth.LoadAccessToken();
var accounts = gas.Management.Accounts.List().Fetch();

现在我通过 WCF 服务调用相同的代码,但出现以下错误

异常消息:无法连接到远程服务器内部异常:对“ https://accounts.google.com/o/oauth2/token ”的 Web 请求失败。内部异常:无法建立连接,因为目标机器主动拒绝它 173.194.70.84:443

知道我做错了什么吗?

4

0 回答 0