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

Heroku.php

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


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