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

Linkedin.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 3.04 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   * Linkedin service.
 015   *
 016   * @author Antoine Corcy <contact@sbin.dk>
 017   *
 018   * @see http://developer.linkedin.com/documents/authentication
 019   */
 020  class Linkedin extends AbstractService
 021  {
 022      /**
 023       * Defined scopes.
 024       *
 025       * @see https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context
 026       */
 027      const SCOPE_R_LITEPROFILE = 'r_liteprofile';
 028      const SCOPE_R_FULLPROFILE = 'r_fullprofile';
 029      const SCOPE_R_EMAILADDRESS = 'r_emailaddress';
 030      const SCOPE_R_NETWORK = 'r_network';
 031      const SCOPE_R_CONTACTINFO = 'r_contactinfo';
 032      const SCOPE_RW_NUS = 'rw_nus';
 033      const SCOPE_RW_COMPANY_ADMIN = 'rw_company_admin';
 034      const SCOPE_RW_GROUPS = 'rw_groups';
 035      const SCOPE_W_MESSAGES = 'w_messages';
 036      const SCOPE_W_MEMBER_SOCIAL = 'w_member_social';
 037   
 038      public function __construct(
 039          CredentialsInterface $credentials,
 040          ClientInterface $httpClient,
 041          TokenStorageInterface $storage,
 042          $scopes = [],
 043          ?UriInterface $baseApiUri = null
 044      ) {
 045          if (count($scopes) === 0) {
 046              $scopes = [self::SCOPE_R_LITEPROFILE, self::SCOPE_R_EMAILADDRESS];
 047          }
 048   
 049          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
 050   
 051          if (null === $baseApiUri) {
 052              $this->baseApiUri = new Uri('https://api.linkedin.com/v2/');
 053          }
 054      }
 055   
 056      /**
 057       * {@inheritdoc}
 058       */
 059      public function getAuthorizationEndpoint()
 060      {
 061          return new Uri('https://www.linkedin.com/oauth/v2/authorization');
 062      }
 063   
 064      /**
 065       * {@inheritdoc}
 066       */
 067      public function getAccessTokenEndpoint()
 068      {
 069          return new Uri('https://www.linkedin.com/oauth/v2/accessToken');
 070      }
 071   
 072      /**
 073       * {@inheritdoc}
 074       */
 075      protected function getAuthorizationMethod()
 076      {
 077          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
 078      }
 079   
 080      /**
 081       * {@inheritdoc}
 082       */
 083      protected function parseAccessTokenResponse($responseBody)
 084      {
 085          $data = json_decode($responseBody, true);
 086   
 087          if (null === $data || !is_array($data)) {
 088              throw new TokenResponseException('Unable to parse response.');
 089          } elseif (isset($data['error'])) {
 090              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
 091          }
 092   
 093          $token = new StdOAuth2Token();
 094          $token->setAccessToken($data['access_token']);
 095          $token->setLifeTime($data['expires_in']);
 096   
 097          if (isset($data['refresh_token'])) {
 098              $token->setRefreshToken($data['refresh_token']);
 099              unset($data['refresh_token']);
 100          }
 101   
 102          unset($data['access_token'], $data['expires_in']);
 103   
 104          $token->setExtraParams($data);
 105   
 106          return $token;
 107      }
 108  }
 109