【发布时间】:2021-11-02 09:22:18
【问题描述】:
我正在尝试使用 php 集成谷歌登录 api。我还应该插入用户信息和其他详细信息。每次我应该插入或更新用户信息并根据信息创建会话,或者我可以根据令牌创建会话而不插入。
if (isset($_GET['code'])) {
$token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
$client->setAccessToken($token['access_token']);
$arr_token = $client->getAccessToken();
$_SESSION['access_token'] = $arr_token['access_token'];
// get profile info
$google_oauth = new Google_Service_Oauth2($client);
$google_account_info = $google_oauth->userinfo->get();
$email = $google_account_info->email;
$name = $google_account_info->name;
//Insert Google AUthentication data in databse
【问题讨论】:
-
请展示你到目前为止所做的尝试。
-
请提供足够的代码,以便其他人更好地理解或重现问题。
标签: php google-signin