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

Box.php

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


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