在哪里可以找到为 Google App 保存的 PHP 凭据

莱昂

我已经编写了一个 PHP 项目来更新 Google 电子表格,而目前,我正在使用代码

require_once __DIR__ . '/vendor/autoload.php';
define('APPLICATION_NAME', 'Google Sheets API PHP Quickstart');
define('CREDENTIALS_PATH', '~/.credentials/sheets.googleapis.com-php-quickstart.json');
define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json');
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/sheets.googleapis.com-php-quickstart.json
define('SCOPES', implode(' ', array(
  Google_Service_Sheets::SPREADSHEETS)
));

但是我找不到凭据的存储位置,因此当我更改帐户时,我遇到一个问题是“来电者没有权限”,我认为它仍在使用旧凭据。谁能告诉我在哪里可以找到它?

谢谢

阿别利塔

基于此PHP 快速入门示例saved credentials保存在$credentialsPath = expandHomeDirectory(CREDENTIALS_PATH);

// Load previously authorized credentials from a file.
$credentialsPath = expandHomeDirectory(CREDENTIALS_PATH);
if (file_exists($credentialsPath)) {
  $accessToken = json_decode(file_get_contents($credentialsPath), true);
} else {
  // Request authorization from the user.
  $authUrl = $client->createAuthUrl();
  printf("Open the following link in your browser:\n%s\n", $authUrl);
  print 'Enter verification code: ';
  $authCode = trim(fgets(STDIN));

  // Exchange authorization code for an access token.
  $accessToken = $client->fetchAccessTokenWithAuthCode($authCode);

  // Store the credentials to disk.
  if(!file_exists(dirname($credentialsPath))) {
    mkdir(dirname($credentialsPath), 0700, true);
  }
  file_put_contents($credentialsPath, json_encode($accessToken));
  printf("Credentials saved to %s\n", $credentialsPath);
}
$client->setAccessToken($accessToken);

您可以查看此文档以获取更多信息:Using OAuth 2.0 for Web Server Applications

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在哪里保存Azure Cloud Storage凭据

来自分类Dev

Google App Engine imap无效凭据

来自分类Dev

在PHP脚本中将MySQL凭据存储在哪里?

来自分类Dev

我应该在哪里存储 Google App Engine 的 Oauth2 凭据(client_id 和 client_secret)?

来自分类Dev

防止将Google凭据保存在android中

来自分类Dev

使用 Android 登录 Google 时保存用户凭据?

来自分类Dev

在哪里可以找到Google Play的viewpagerindicator?

来自分类Dev

在哪里可以找到Microsoft App的APP ID URI?

来自分类Dev

在哪里可以找到“保存到Ubuntu One”功能?

来自分类Dev

在哪里可以找到“保存到Ubuntu One”功能?

来自分类Dev

在哪里可以找到14.04上保存的wifi密码?

来自分类Dev

您在哪里可以找到Mac App Store分析

来自分类Dev

在哪里可以找到QuickBooks在线App的RealM ID

来自分类Dev

您在哪里可以找到Mac App Store分析

来自分类Dev

我的凭据存储在哪里?

来自分类Dev

我在哪里可以在Google日历中找到eventId?

来自分类Dev

在哪里可以找到google-play-services_lib.jar?

来自分类Dev

在哪里可以找到Google Cardboard的计算结果?

来自分类Dev

在哪里可以找到Google Calendar API的版本?

来自分类Dev

在哪里可以找到Google Play服务v4.2.34?

来自分类Dev

在哪里可以找到Google云端硬盘图标?

来自分类Dev

在哪里可以找到Google地理编码的替代方案?

来自分类Dev

在哪里可以找到旧版 google-cloud-python 的文档?

来自分类Dev

在哪里可以找到PHP严格标准定义

来自分类Dev

验证Google凭据

来自分类Dev

在Google App Engine上部署后,在哪里可以看到nodejs日志?

来自分类Dev

在Google App Engine上部署后,在哪里可以看到nodejs日志?

来自分类Dev

将凭据存储在Google App Engine Java服务器中

来自分类Dev

如何在Google App Engine中安全存储外部身份验证凭据

Related 相关文章

  1. 1

    在哪里保存Azure Cloud Storage凭据

  2. 2

    Google App Engine imap无效凭据

  3. 3

    在PHP脚本中将MySQL凭据存储在哪里?

  4. 4

    我应该在哪里存储 Google App Engine 的 Oauth2 凭据(client_id 和 client_secret)?

  5. 5

    防止将Google凭据保存在android中

  6. 6

    使用 Android 登录 Google 时保存用户凭据?

  7. 7

    在哪里可以找到Google Play的viewpagerindicator?

  8. 8

    在哪里可以找到Microsoft App的APP ID URI?

  9. 9

    在哪里可以找到“保存到Ubuntu One”功能?

  10. 10

    在哪里可以找到“保存到Ubuntu One”功能?

  11. 11

    在哪里可以找到14.04上保存的wifi密码?

  12. 12

    您在哪里可以找到Mac App Store分析

  13. 13

    在哪里可以找到QuickBooks在线App的RealM ID

  14. 14

    您在哪里可以找到Mac App Store分析

  15. 15

    我的凭据存储在哪里?

  16. 16

    我在哪里可以在Google日历中找到eventId?

  17. 17

    在哪里可以找到google-play-services_lib.jar?

  18. 18

    在哪里可以找到Google Cardboard的计算结果?

  19. 19

    在哪里可以找到Google Calendar API的版本?

  20. 20

    在哪里可以找到Google Play服务v4.2.34?

  21. 21

    在哪里可以找到Google云端硬盘图标?

  22. 22

    在哪里可以找到Google地理编码的替代方案?

  23. 23

    在哪里可以找到旧版 google-cloud-python 的文档?

  24. 24

    在哪里可以找到PHP严格标准定义

  25. 25

    验证Google凭据

  26. 26

    在Google App Engine上部署后,在哪里可以看到nodejs日志?

  27. 27

    在Google App Engine上部署后,在哪里可以看到nodejs日志?

  28. 28

    将凭据存储在Google App Engine Java服务器中

  29. 29

    如何在Google App Engine中安全存储外部身份验证凭据

热门标签

归档