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

Heroku.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 3.23 KiB


001  <?php
002   
003  namespace OAuth\OAuth2\Service;
004   
005  use OAuth\OAuth2\Token\StdOAuth2Token;
006  use OAuth\Common\Http\Exception\TokenResponseException;
007  use OAuth\Common\Http\Uri\Uri;
008  use OAuth\Common\Consumer\CredentialsInterface;
009  use OAuth\Common\Http\Client\ClientInterface;
010  use OAuth\Common\Storage\TokenStorageInterface;
011  use OAuth\Common\Http\Uri\UriInterface;
012   
013  /**
014   * Heroku service.
015   *
016   * @author Thomas Welton <thomaswelton@me.com>
017   * @link https://devcenter.heroku.com/articles/oauth
018   */
019  class Heroku extends AbstractService
020  {
021      /**
022       * Defined scopes
023       * @link https://devcenter.heroku.com/articles/oauth#scopes
024       */
025      const SCOPE_GLOBAL          = 'global';
026      const SCOPE_IDENTITY        = 'identity';
027      const SCOPE_READ            = 'read';
028      const SCOPE_WRITE           = 'write';
029      const SCOPE_READ_PROTECTED  = 'read-protected';
030      const SCOPE_WRITE_PROTECTED = 'write-protected';
031   
032      /**
033      * {@inheritdoc}
034      */
035      public function __construct(
036          CredentialsInterface $credentials,
037          ClientInterface $httpClient,
038          TokenStorageInterface $storage,
039          $scopes = array(),
040          UriInterface $baseApiUri = null
041      ) {
042          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
043   
044          if (null === $baseApiUri) {
045              $this->baseApiUri = new Uri('https://api.heroku.com/');
046          }
047      }
048   
049      /**
050       * {@inheritdoc}
051       */
052      public function getAuthorizationEndpoint()
053      {
054          return new Uri('https://id.heroku.com/oauth/authorize');
055      }
056   
057      /**
058       * {@inheritdoc}
059       */
060      public function getAccessTokenEndpoint()
061      {
062          return new Uri('https://id.heroku.com/oauth/token');
063      }
064   
065      /**
066       * {@inheritdoc}
067       */
068      protected function getAuthorizationMethod()
069      {
070          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
071      }
072   
073      /**
074       * {@inheritdoc}
075       */
076      protected function parseAccessTokenResponse($responseBody)
077      {
078          $data = json_decode($responseBody, true);
079   
080          if (null === $data || !is_array($data)) {
081              throw new TokenResponseException('Unable to parse response.');
082          } elseif (isset($data['error_description']) || isset($data['error'])) {
083              throw new TokenResponseException(
084                  sprintf(
085                      'Error in retrieving token: "%s"',
086                      isset($data['error_description']) ? $data['error_description'] : $data['error']
087                  )
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']);
101          unset($data['expires_in']);
102   
103          $token->setExtraParams($data);
104   
105          return $token;
106      }
107   
108      /**
109       * {@inheritdoc}
110       */
111      protected function getExtraOAuthHeaders()
112      {
113          return array('Accept' => 'application/vnd.heroku+json; version=3');
114      }
115   
116      /**
117       * {@inheritdoc}
118       */
119      protected function getExtraApiHeaders()
120      {
121          return array('Accept' => 'application/vnd.heroku+json; version=3', 'Content-Type' => 'application/json');
122      }
123  }
124