Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Nest.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 2.65 KiB


001  <?php
002  /**
003   * Nest service.
004   *
005   * @author  Pedro Amorim <contact@pamorim.fr>
006   * @license http://www.opensource.org/licenses/mit-license.html MIT License
007   *
008   * @see    https://developer.nest.com/documentation
009   */
010   
011  namespace OAuth\OAuth2\Service;
012   
013  use OAuth\Common\Consumer\CredentialsInterface;
014  use OAuth\Common\Http\Client\ClientInterface;
015  use OAuth\Common\Http\Exception\TokenResponseException;
016  use OAuth\Common\Http\Uri\Uri;
017  use OAuth\Common\Http\Uri\UriInterface;
018  use OAuth\Common\Storage\TokenStorageInterface;
019  use OAuth\OAuth2\Token\StdOAuth2Token;
020   
021  /**
022   * Nest service.
023   *
024   * @author  Pedro Amorim <contact@pamorim.fr>
025   * @license http://www.opensource.org/licenses/mit-license.html MIT License
026   *
027   * @see    https://developer.nest.com/documentation
028   */
029  class Nest extends AbstractService
030  {
031      public function __construct(
032          CredentialsInterface $credentials,
033          ClientInterface $httpClient,
034          TokenStorageInterface $storage,
035          $scopes = [],
036          ?UriInterface $baseApiUri = null
037      ) {
038          parent::__construct(
039              $credentials,
040              $httpClient,
041              $storage,
042              $scopes,
043              $baseApiUri,
044              true
045          );
046   
047          if (null === $baseApiUri) {
048              $this->baseApiUri = new Uri('https://developer-api.nest.com/');
049          }
050      }
051   
052      /**
053       * {@inheritdoc}
054       */
055      public function getAuthorizationEndpoint()
056      {
057          return new Uri('https://home.nest.com/login/oauth2');
058      }
059   
060      /**
061       * {@inheritdoc}
062       */
063      public function getAccessTokenEndpoint()
064      {
065          return new Uri('https://api.home.nest.com/oauth2/access_token');
066      }
067   
068      /**
069       * {@inheritdoc}
070       */
071      protected function getAuthorizationMethod()
072      {
073          return static::AUTHORIZATION_METHOD_QUERY_STRING_V4;
074      }
075   
076      /**
077       * {@inheritdoc}
078       */
079      protected function parseAccessTokenResponse($responseBody)
080      {
081          $data = json_decode($responseBody, true);
082   
083          if (null === $data || !is_array($data)) {
084              throw new TokenResponseException('Unable to parse response.');
085          } elseif (isset($data['error'])) {
086              throw new TokenResponseException(
087                  'Error in retrieving token: "' . $data['error'] . '"'
088              );
089          }
090   
091          $token = new StdOAuth2Token();
092          $token->setAccessToken($data['access_token']);
093          $token->setLifeTime($data['expires_in']);
094   
095          if (isset($data['refresh_token'])) {
096              $token->setRefreshToken($data['refresh_token']);
097              unset($data['refresh_token']);
098          }
099   
100          unset($data['access_token'], $data['expires_in']);
101   
102          $token->setExtraParams($data);
103   
104          return $token;
105      }
106  }
107