Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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

Box.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.57 KiB


 01  <?php
 02  namespace OAuth\OAuth2\Service;
 03   
 04  use OAuth\OAuth2\Token\StdOAuth2Token;
 05  use OAuth\Common\Http\Exception\TokenResponseException;
 06  use OAuth\Common\Http\Uri\Uri;
 07  use OAuth\Common\Consumer\Credentials;
 08  use OAuth\Common\Http\Client\ClientInterface;
 09  use OAuth\Common\Storage\TokenStorageInterface;
 10  use OAuth\Common\Http\Uri\UriInterface;
 11   
 12  /**
 13   * Box service.
 14   *
 15   * @author Antoine Corcy <contact@sbin.dk>
 16   * @link https://developers.box.com/oauth/
 17   */
 18  class Box extends AbstractService
 19  {
 20      public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 21      {
 22          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
 23          if( null === $baseApiUri ) {
 24              $this->baseApiUri = new Uri('https://api.box.com/2.0/');
 25          }
 26      }
 27   
 28      /**
 29       * @return \OAuth\Common\Http\Uri\UriInterface
 30       */
 31      public function getAuthorizationEndpoint()
 32      {
 33          return new Uri('https://www.box.com/api/oauth2/authorize');
 34      }
 35   
 36      /**
 37       * @return \OAuth\Common\Http\Uri\UriInterface
 38       */
 39      public function getAccessTokenEndpoint()
 40      {
 41          return new Uri('https://www.box.com/api/oauth2/token');
 42      }
 43   
 44      /**
 45       * Returns a class constant from ServiceInterface defining the authorization method used for the API
 46       * Header is the sane default.
 47       *
 48       * @return int
 49       */
 50      protected function getAuthorizationMethod()
 51      {
 52          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
 53      }
 54   
 55      /**
 56       * @param string $responseBody
 57       * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth2\Token\StdOAuth2Token
 58       * @throws \OAuth\Common\Http\Exception\TokenResponseException
 59       */
 60      protected function parseAccessTokenResponse($responseBody)
 61      {
 62          $data = json_decode( $responseBody, true );
 63   
 64          if( null === $data || !is_array($data) ) {
 65              throw new TokenResponseException('Unable to parse response.');
 66          } elseif( isset($data['error'] ) ) {
 67              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
 68          }
 69   
 70          $token = new StdOAuth2Token();
 71   
 72          $token->setAccessToken( $data['access_token'] );
 73          $token->setLifeTime( $data['expires_in'] );
 74   
 75          if( isset($data['refresh_token'] ) ) {
 76              $token->setRefreshToken( $data['refresh_token'] );
 77              unset($data['refresh_token']);
 78          }
 79   
 80          unset( $data['access_token'] );
 81          unset( $data['expires_in'] );
 82          $token->setExtraParams( $data );
 83   
 84          return $token;
 85      }
 86  }
 87