12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\libs\google;
- use Google\Client;
- use Illuminate\Support\Facades\Config;
- class GoogleOauth
- {
- private static $config;
- private static $client;
- public function __construct()
- {
- self::$config = Config::get('swdz.goodle');
- self::$client = new Client([
- 'client_id' => self::$config['client_id'],
- 'client_secret' => self::$config['client_secret'],
- 'redirect_uri' => self::$config['redirect_uri'],
- 'scopes' => self::$config['scopes']
- ]);
- }
- /**
- * APP通过code换取用户信息
- *
- * @return array|false
- * @throws \Psr\Container\ContainerExceptionInterface
- * @throws \Psr\Container\NotFoundExceptionInterface
- */
- public static function appAuth(){
- $code = request()->get('code', null);
- return self::$client->verifyIdToken($code);
- }
- /**
- * WEB打开授权页面(待补充)
- *
- * @return void
- */
- public static function webAuth(){
- }
- }
|