php - Google API 中的令牌格式无效
问题描述
当我想确保使用谷歌帐户登录时,我发现了一些错误。错误是:
致命错误:未捕获的 InvalidArgumentException:C:\xampp\htdocs\google\googleAPI\src\Google\Client.php:434 中的令牌格式无效 堆栈跟踪:#0 C:\xampp\htdocs\google\callback.php(5) : Google_Client->setAccessToken(Array) #1 {main} 在第 434 行的 C:\xampp\htdocs\google\googleAPI\src\Google\Client.php 中抛出
然后这是我的代码:
<?php
require_once('config.php');
if (isset($_SESSION['accessToken'])){
$client->setAccessToken($_SESSION['accessToken']);
}
else if (isset($_GET['code'])) {
$token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
$_SESSION['accessToken'] = $token;
}
else{
header("location: index.php");
}
$oAtuth = new Google_Service_Oauth2($client);
$user = $oAtuth->userinfo->get();
echo "<pre>";
print_r($user);
?>
请告诉我这段代码有什么问题
解决方案
您在 中的令牌值错误$_SESSION['accessToken']
。
推荐阅读
- huawei-mobile-services - 集成HMS Core Map Kit 4.0.1.301后同步资源文件冲突
- python - 每个直方图曲线下方的渐变填充 - Python
- typescript - 对象接口打字稿的对象
- javascript - 如何将 onclick 事件存储在 Django 数据库中?
- ruby-on-rails - 在 IIS 上的 Rails 应用程序上配置 ruby 时出现异常
- c# - C# Renci.SshNet.Common.SshAuthenticationException:'权限被拒绝(密码)。'
- bootstrap-4 - 如何在移动屏幕中创建嵌套 3 行的引导程序,但在大屏幕中,一行图像在左上角,另外两个在右下角
- c++ - cplusplus connet mysql 显示数据问题
- javascript - react-table 在 next.js 中出现渲染问题
- react-native - 如何在原生反应中使用 Expo Camera?