4

token-idGoogleによって生成されたクライアントAndroidアプリから受け取りました。
ユーザーにソーシャルライトを許可するにはどうすればよいですか?
現在 google_api クライアントを使用していますが、Socialte ほど便利ではありません。

4

3 に答える 3

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.

于 2016-12-28T07:24:29.837 に答える
3

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

于 2020-08-15T00:28:52.303 に答える