token-id
Googleによって生成されたクライアントAndroidアプリから受け取りました。
ユーザーにソーシャルライトを許可するにはどうすればよいですか?
現在 google_api クライアントを使用していますが、Socialte ほど便利ではありません。
3 に答える
If you can obtain a server auth code then you can exchange it for an accessToken and use it to query the Google+ API.
In my case, I am using a cordova library
https://github.com/EddyVerbruggen/cordova-plugin-googleplus
This will give you (if configured for 'offline') a serverAuthCode
You can send that up to your server. Then, to convert it to an accessToken you can call this socialite method:
$driver = Socialite::driver($provider); // provider is 'google' here
$access_token = $driver->getAccessToken($serverAuthCode);
Then you can get the user info using this token:
$socialUser = $driver->userFromToken($access_token);
Just wanted to help anyone else who was struggling with this.
PHP Google API クライアント ライブラリの使用
コンポーザー経由で最初にライブラリをインストールする
$ composer require google/apiclient
$client = new Google_Client(['client_id' => env('Google_CLIENT_ID')]); // Specify the CLIENT_ID of the app that accesses the backend
$payload = $client->verifyIdToken($id_token);
if ($payload) {
$userid = $payload['sub'];
// If request specified a G Suite domain:
//$domain = $payload['hd'];
} else {
// Invalid ID token
}
詳細については、それを確認してください
https://developers.google.com/identity/sign-in/android/backend-auth?authuser=2