Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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