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

RunKeeper.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 2.67 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   * RunKeeper service.
015   *
016   * @see http://runkeeper.com/developer/healthgraph/registration-authorization
017   */
018  class RunKeeper extends AbstractService
019  {
020      public function __construct(
021          CredentialsInterface $credentials,
022          ClientInterface $httpClient,
023          TokenStorageInterface $storage,
024          $scopes = [],
025          ?UriInterface $baseApiUri = null
026      ) {
027          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
028   
029          if (null === $baseApiUri) {
030              $this->baseApiUri = new Uri('https://api.runkeeper.com/');
031          }
032      }
033   
034      /**
035       * {@inheritdoc}
036       */
037      public function getAuthorizationUri(array $additionalParameters = [])
038      {
039          $parameters = array_merge(
040              $additionalParameters,
041              [
042                  'client_id' => $this->credentials->getConsumerId(),
043                  'redirect_uri' => $this->credentials->getCallbackUrl(),
044                  'response_type' => 'code',
045              ]
046          );
047   
048          $parameters['scope'] = implode(' ', $this->scopes);
049   
050          // Build the url
051          $url = clone $this->getAuthorizationEndpoint();
052          foreach ($parameters as $key => $val) {
053              $url->addToQuery($key, $val);
054          }
055   
056          return $url;
057      }
058   
059      /**
060       * {@inheritdoc}
061       */
062      public function getAuthorizationEndpoint()
063      {
064          return new Uri('https://runkeeper.com/apps/authorize');
065      }
066   
067      /**
068       * {@inheritdoc}
069       */
070      public function getAccessTokenEndpoint()
071      {
072          return new Uri('https://runkeeper.com/apps/token');
073      }
074   
075      /**
076       * {@inheritdoc}
077       */
078      protected function getAuthorizationMethod()
079      {
080          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
081      }
082   
083      /**
084       * {@inheritdoc}
085       */
086      protected function parseAccessTokenResponse($responseBody)
087      {
088          $data = json_decode($responseBody, true);
089   
090          if (null === $data || !is_array($data)) {
091              throw new TokenResponseException('Unable to parse response.');
092          } elseif (isset($data['error'])) {
093              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
094          }
095   
096          $token = new StdOAuth2Token();
097          $token->setAccessToken($data['access_token']);
098   
099          unset($data['access_token']);
100   
101          $token->setExtraParams($data);
102   
103          return $token;
104      }
105  }
106