Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

Strava.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 3.92 KiB


 001  <?php
 002  /**
 003   * Strava service.
 004   *
 005   * @author  Pedro Amorim <contact@pamorim.fr>
 006   * @license http://www.opensource.org/licenses/mit-license.html MIT License
 007   *
 008   * @see    http://strava.github.io/
 009   * @see    http://strava.github.io/api/v3/oauth/
 010   */
 011   
 012  namespace OAuth\OAuth2\Service;
 013   
 014  use OAuth\Common\Consumer\CredentialsInterface;
 015  use OAuth\Common\Http\Client\ClientInterface;
 016  use OAuth\Common\Http\Exception\TokenResponseException;
 017  use OAuth\Common\Http\Uri\Uri;
 018  use OAuth\Common\Http\Uri\UriInterface;
 019  use OAuth\Common\Storage\TokenStorageInterface;
 020  use OAuth\OAuth2\Service\Exception\InvalidAccessTypeException;
 021  use OAuth\OAuth2\Token\StdOAuth2Token;
 022   
 023  /**
 024   * Strava service.
 025   *
 026   * @author  Pedro Amorim <contact@pamorim.fr>
 027   * @license http://www.opensource.org/licenses/mit-license.html MIT License
 028   *
 029   * @see    http://strava.github.io/
 030   * @see    http://strava.github.io/api/v3/oauth/
 031   */
 032  class Strava extends AbstractService
 033  {
 034      /**
 035       * Scopes.
 036       */
 037      // default
 038      const SCOPE_PUBLIC = 'public';
 039      // Modify activities, upload on the user’s behalf
 040      const SCOPE_WRITE = 'write';
 041      // View private activities and data within privacy zones
 042      const SCOPE_VIEW_PRIVATE = 'view_private';
 043   
 044      protected $approvalPrompt = 'auto';
 045   
 046      public function __construct(
 047          CredentialsInterface $credentials,
 048          ClientInterface $httpClient,
 049          TokenStorageInterface $storage,
 050          $scopes = [],
 051          ?UriInterface $baseApiUri = null
 052      ) {
 053          if (empty($scopes)) {
 054              $scopes = [self::SCOPE_PUBLIC];
 055          }
 056   
 057          parent::__construct(
 058              $credentials,
 059              $httpClient,
 060              $storage,
 061              $scopes,
 062              $baseApiUri,
 063              true
 064          );
 065   
 066          if (null === $baseApiUri) {
 067              $this->baseApiUri = new Uri('https://www.strava.com/api/v3/');
 068          }
 069      }
 070   
 071      /**
 072       * {@inheritdoc}
 073       */
 074      public function getAuthorizationEndpoint()
 075      {
 076          return new Uri('https://www.strava.com/oauth/authorize?approval_prompt=' . $this->approvalPrompt);
 077      }
 078   
 079      /**
 080       * {@inheritdoc}
 081       */
 082      public function getAccessTokenEndpoint()
 083      {
 084          return new Uri('https://www.strava.com/oauth/token');
 085      }
 086   
 087      /**
 088       * {@inheritdoc}
 089       */
 090      protected function getAuthorizationMethod()
 091      {
 092          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
 093      }
 094   
 095      /**
 096       * {@inheritdoc}
 097       */
 098      protected function parseAccessTokenResponse($responseBody)
 099      {
 100          $data = json_decode($responseBody, true);
 101   
 102          if (null === $data || !is_array($data)) {
 103              throw new TokenResponseException('Unable to parse response.');
 104          } elseif (isset($data['error_description'])) {
 105              throw new TokenResponseException(
 106                  'Error in retrieving token: "' . $data['error_description'] . '"'
 107              );
 108          } elseif (isset($data['error'])) {
 109              throw new TokenResponseException(
 110                  'Error in retrieving token: "' . $data['error'] . '"'
 111              );
 112          }
 113   
 114          $token = new StdOAuth2Token();
 115          $token->setAccessToken($data['access_token']);
 116   
 117          if (isset($data['expires_in'])) {
 118              $token->setLifeTime($data['expires_in']);
 119              unset($data['expires_in']);
 120          }
 121          if (isset($data['refresh_token'])) {
 122              $token->setRefreshToken($data['refresh_token']);
 123              unset($data['refresh_token']);
 124          }
 125   
 126          unset($data['access_token']);
 127   
 128          $token->setExtraParams($data);
 129   
 130          return $token;
 131      }
 132   
 133      public function setApprouvalPrompt($prompt): void
 134      {
 135          if (!in_array($prompt, ['auto', 'force'], true)) {
 136              // @todo Maybe could we rename this exception
 137              throw new InvalidAccessTypeException('Invalid approuvalPrompt, expected either auto or force.');
 138          }
 139          $this->approvalPrompt = $prompt;
 140      }
 141   
 142      /**
 143       * {@inheritdoc}
 144       */
 145      protected function getScopesDelimiter()
 146      {
 147          return ',';
 148      }
 149  }
 150