【问题标题】:Google Service Accounts on localhost本地主机上的 Google 服务帐户
【发布时间】:2016-08-04 10:52:52
【问题描述】:

我正在使用 Google Apps for Work,并且有一个服务帐户来访问 PHP 中的 Drive API。

我现在的代码是:

$client = new Google_Client();
$client->setApplicationName('MyApp');
$key = file_get_contents("/path/to/secure/key");
$cred = new Google_Auth_AssertionCredentials(
      "serviceaccount@myapp.iam.gserviceaccount.com",
      array('https://www.googleapis.com/auth/drive', 'https://spreadsheets.google.com/feeds'),
      $key, 'keysecretgoeshere', 'http://oauth.net/grant_type/jwt/1.0/bearer', "email@domain.com"
    );
$client->setAssertionCredentials($cred);

当我将它上传到我的外部托管的 Apache 服务器时,这非常有效。奇怪的是,我还有一个本地服务器,使用 EasyPHP 在本地测试,一访问页面,就出现“无法访问此站点。连接已重置”错误。

关于为什么它不能从 localhost 工作,我有什么遗漏吗? 可能是未安装 PHP 扩展或一些 cURL/openSSL 问题?

【问题讨论】:

    标签: php google-app-engine google-api google-apps service-accounts


    【解决方案1】:

    在每个点对代码进行断点后,这是 OpenSSL 的问题。 可以在这里找到解决方案:

    PHP openssl_sign DIES

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-09
      • 1970-01-01
      • 1970-01-01
      • 2021-10-07
      • 1970-01-01
      • 2018-02-26
      • 2014-05-29
      • 2013-08-07
      相关资源
      最近更新 更多