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

Amazon.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 2.70 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   * Amazon service.
15   *
16   * @author Flávio Heleno <flaviohbatista@gmail.com>
17   *
18   * @see https://images-na.ssl-images-amazon.com/images/G/01/lwa/dev/docs/website-developer-guide._TTH_.pdf
19   */
20  class Amazon extends AbstractService
21  {
22      /**
23       * Defined scopes.
24       *
25       * @see https://images-na.ssl-images-amazon.com/images/G/01/lwa/dev/docs/website-developer-guide._TTH_.pdf
26       */
27      const SCOPE_PROFILE = 'profile';
28      const SCOPE_POSTAL_CODE = 'postal_code';
29   
30      public function __construct(
31          CredentialsInterface $credentials,
32          ClientInterface $httpClient,
33          TokenStorageInterface $storage,
34          $scopes = [],
35          ?UriInterface $baseApiUri = null
36      ) {
37          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
38   
39          if (null === $baseApiUri) {
40              $this->baseApiUri = new Uri('https://api.amazon.com/');
41          }
42      }
43   
44      /**
45       * {@inheritdoc}
46       */
47      public function getAuthorizationEndpoint()
48      {
49          return new Uri('https://www.amazon.com/ap/oa');
50      }
51   
52      /**
53       * {@inheritdoc}
54       */
55      public function getAccessTokenEndpoint()
56      {
57          return new Uri('https://www.amazon.com/ap/oatoken');
58      }
59   
60      /**
61       * {@inheritdoc}
62       */
63      protected function getAuthorizationMethod()
64      {
65          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
66      }
67   
68      /**
69       * {@inheritdoc}
70       */
71      protected function parseAccessTokenResponse($responseBody)
72      {
73          $data = json_decode($responseBody, true);
74   
75          if (null === $data || !is_array($data)) {
76              throw new TokenResponseException('Unable to parse response.');
77          } elseif (isset($data['error_description'])) {
78              throw new TokenResponseException('Error in retrieving token: "' . $data['error_description'] . '"');
79          } elseif (isset($data['error'])) {
80              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
81          }
82   
83          $token = new StdOAuth2Token();
84          $token->setAccessToken($data['access_token']);
85          $token->setLifeTime($data['expires_in']);
86   
87          if (isset($data['refresh_token'])) {
88              $token->setRefreshToken($data['refresh_token']);
89              unset($data['refresh_token']);
90          }
91   
92          unset($data['access_token'], $data['expires_in']);
93   
94          $token->setExtraParams($data);
95   
96          return $token;
97      }
98  }
99