Oauth.php 949 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\libs\google;
  3. use Google\Client;
  4. use Illuminate\Support\Facades\Config;
  5. class Oauth
  6. {
  7. public function __construct()
  8. {
  9. $this->config = Config::get('swdz.goodle');
  10. $this->client = new Client([
  11. 'client_id' => $this->config['client_id'],
  12. 'client_secret' => $this->config['client_secret'],
  13. 'redirect_uri' => $this->config['redirect_uri'],
  14. 'scopes' => $this->config['scopes']
  15. ]);
  16. }
  17. /**
  18. * APP通过code换取用户信息
  19. *
  20. * @return array|false
  21. * @throws \Psr\Container\ContainerExceptionInterface
  22. * @throws \Psr\Container\NotFoundExceptionInterface
  23. */
  24. public function appAuth(){
  25. $code = request()->get('code', null);
  26. return $this->client->verifyIdToken($code);
  27. }
  28. /**
  29. * WEB打开授权页面(待补充)
  30. *
  31. * @return void
  32. */
  33. public function webAuth(){
  34. }
  35. }