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