Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
google.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\auth\provider\oauth\service;
015
016 /**
017 * Google OAuth service
018 */
019 class google extends base
020 {
021 /**
022 * phpBB config
023 *
024 * @var \phpbb\config\config
025 */
026 protected $config;
027
028 /**
029 * phpBB request
030 *
031 * @var \phpbb\request\request_interface
032 */
033 protected $request;
034
035 /**
036 * Constructor
037 *
038 * @param \phpbb\config\config $config
039 * @param \phpbb\request\request_interface $request
040 */
041 public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)
042 {
043 $this->config = $config;
044 $this->request = $request;
045 }
046
047 /**
048 * {@inheritdoc}
049 */
050 public function get_auth_scope()
051 {
052 return array(
053 'userinfo_email',
054 'userinfo_profile',
055 );
056 }
057
058 /**
059 * {@inheritdoc}
060 */
061 public function get_service_credentials()
062 {
063 return array(
064 'key' => $this->config['auth_oauth_google_key'],
065 'secret' => $this->config['auth_oauth_google_secret'],
066 );
067 }
068
069 /**
070 * {@inheritdoc}
071 */
072 public function perform_auth_login()
073 {
074 if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google))
075 {
076 throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
077 }
078
079 // This was a callback request, get the token
080 $this->service_provider->requestAccessToken($this->request->variable('code', ''));
081
082 // Send a request with it
083 $result = json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
084
085 // Return the unique identifier
086 return $result['id'];
087 }
088
089 /**
090 * {@inheritdoc}
091 */
092 public function perform_token_auth()
093 {
094 if (!($this->service_provider instanceof \OAuth\OAuth2\Service\Google))
095 {
096 throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE');
097 }
098
099 // Send a request with it
100 $result = json_decode($this->service_provider->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
101
102 // Return the unique identifier
103 return $result['id'];
104 }
105 }
106