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

JawboneUP.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 3.93 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   * Jawbone UP service.
 015   *
 016   * @author Andrii Gakhov <andrii.gakhov@gmail.com>
 017   *
 018   * @see https://jawbone.com/up/developer/authentication
 019   */
 020  class JawboneUP extends AbstractService
 021  {
 022      /**
 023       * Defined scopes.
 024       *
 025       * @see https://jawbone.com/up/developer/authentication
 026       */
 027      // general information scopes
 028      const SCOPE_BASIC_READ = 'basic_read';
 029      const SCOPE_EXTENDED_READ = 'extended_read';
 030      const SCOPE_LOCATION_READ = 'location_read';
 031      const SCOPE_FRIENDS_READ = 'friends_read';
 032      // mood scopes
 033      const SCOPE_MOOD_READ = 'mood_read';
 034      const SCOPE_MOOD_WRITE = 'mood_write';
 035      // move scopes
 036      const SCOPE_MOVE_READ = 'move_read';
 037      const SCOPE_MOVE_WRITE = 'move_write';
 038      // sleep scopes
 039      const SCOPE_SLEEP_READ = 'sleep_read';
 040      const SCOPE_SLEEP_WRITE = 'sleep_write';
 041      // meal scopes
 042      const SCOPE_MEAL_READ = 'meal_read';
 043      const SCOPE_MEAL_WRITE = 'meal_write';
 044      // weight scopes
 045      const SCOPE_WEIGHT_READ = 'weight_read';
 046      const SCOPE_WEIGHT_WRITE = 'weight_write';
 047      // generic event scopes
 048      const SCOPE_GENERIC_EVENT_READ = 'generic_event_read';
 049      const SCOPE_GENERIC_EVENT_WRITE = 'generic_event_write';
 050   
 051      public function __construct(
 052          CredentialsInterface $credentials,
 053          ClientInterface $httpClient,
 054          TokenStorageInterface $storage,
 055          $scopes = [],
 056          ?UriInterface $baseApiUri = null
 057      ) {
 058          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
 059   
 060          if (null === $baseApiUri) {
 061              $this->baseApiUri = new Uri('https://jawbone.com/nudge/api/v.1.1/');
 062          }
 063      }
 064   
 065      /**
 066       * {@inheritdoc}
 067       */
 068      public function getAuthorizationUri(array $additionalParameters = [])
 069      {
 070          $parameters = array_merge(
 071              $additionalParameters,
 072              [
 073                  'client_id' => $this->credentials->getConsumerId(),
 074                  'redirect_uri' => $this->credentials->getCallbackUrl(),
 075                  'response_type' => 'code',
 076              ]
 077          );
 078   
 079          $parameters['scope'] = implode(' ', $this->scopes);
 080   
 081          // Build the url
 082          $url = clone $this->getAuthorizationEndpoint();
 083          foreach ($parameters as $key => $val) {
 084              $url->addToQuery($key, $val);
 085          }
 086   
 087          return $url;
 088      }
 089   
 090      /**
 091       * {@inheritdoc}
 092       */
 093      public function getAuthorizationEndpoint()
 094      {
 095          return new Uri('https://jawbone.com/auth/oauth2/auth');
 096      }
 097   
 098      /**
 099       * {@inheritdoc}
 100       */
 101      public function getAccessTokenEndpoint()
 102      {
 103          return new Uri('https://jawbone.com/auth/oauth2/token');
 104      }
 105   
 106      /**
 107       * {@inheritdoc}
 108       */
 109      protected function getAuthorizationMethod()
 110      {
 111          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
 112      }
 113   
 114      /**
 115       * {@inheritdoc}
 116       */
 117      protected function parseAccessTokenResponse($responseBody)
 118      {
 119          $data = json_decode($responseBody, true);
 120   
 121          if (null === $data || !is_array($data)) {
 122              throw new TokenResponseException('Unable to parse response.');
 123          } elseif (isset($data['error'])) {
 124              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
 125          }
 126   
 127          $token = new StdOAuth2Token();
 128          $token->setAccessToken($data['access_token']);
 129          $token->setLifeTime($data['expires_in']);
 130   
 131          if (isset($data['refresh_token'])) {
 132              $token->setRefreshToken($data['refresh_token']);
 133              unset($data['refresh_token']);
 134          }
 135   
 136          unset($data['access_token'], $data['expires_in']);
 137   
 138          $token->setExtraParams($data);
 139   
 140          return $token;
 141      }
 142  }
 143