我正在构建一个门户,多个用户可以在其中登录到他们的多个 Gmail 帐户。我已成功检索令牌值,但是,我想将其存储在我的数据库中,但我无法存储它。
下面是我正在使用的代码:
function mInititalize(){
$client = new Google_Client();
$client->addScope('https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://mail.google.com/');
$client->setClientId(Config('gmail.client_id'));
$client->setClientSecret(Config('gmail.client_secret'));
$client->setRedirectUri('http://localhost:81'.Config('gmail.redirect_url'));
$loginURL = $client->createAuthUrl();
return redirect($loginURL);
}
重定向或用户登录后
function mGetToken(){
$token = $client->fetchAccessTokenWithAuthCode( 'code'); // here i get the 'code' from login URL
I pass this code to get token I successfully get token
$oAuth = new Google_Service_Oauth2( $client);
$userData = $oAuth->userinfo_v2_me->get(); // get current user detail
}
我想将$token值存储在数据库中,但收到错误消息
>Serialization of 'Closure' is not allowed
请任何人帮我解决这个问题。谢谢。
萧十郎