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

GitHub.php

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


001  <?php
002  namespace OAuth\OAuth2\Service;
003   
004  use OAuth\OAuth2\Token\StdOAuth2Token;
005  use OAuth\Common\Http\Exception\TokenResponseException;
006  use OAuth\Common\Http\Uri\Uri;
007  use OAuth\Common\Consumer\Credentials;
008  use OAuth\Common\Http\Client\ClientInterface;
009  use OAuth\Common\Storage\TokenStorageInterface;
010  use OAuth\Common\Http\Uri\UriInterface;
011   
012  class GitHub extends AbstractService
013  {
014      /**
015       * Defined scopes, see http://developer.github.com/v3/oauth/ for definitions
016       */
017      const SCOPE_USER = 'user';
018      const SCOPE_PUBLIC_REPO = 'public_repo';
019      const SCOPE_REPO = 'repo';
020      const SCOPE_DELETE_REPO = 'delete_repo';
021      const SCOPE_GIST = 'gist';
022   
023      public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
024      {
025          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
026          if( null === $baseApiUri ) {
027              $this->baseApiUri = new Uri('https://api.github.com/');
028          }
029      }
030   
031      /**
032       * @return \OAuth\Common\Http\Uri\UriInterface
033       */
034      public function getAuthorizationEndpoint()
035      {
036          return new Uri('https://github.com/login/oauth/authorize');
037      }
038   
039      /**
040       * @return \OAuth\Common\Http\Uri\UriInterface
041       */
042      public function getAccessTokenEndpoint()
043      {
044          return new Uri('https://github.com/login/oauth/access_token');
045      }
046   
047      /**
048       * @param string $responseBody
049       * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth2\Token\StdOAuth2Token
050       * @throws \OAuth\Common\Http\Exception\TokenResponseException
051       */
052      protected function parseAccessTokenResponse($responseBody)
053      {
054          $data = json_decode( $responseBody, true );
055   
056          if( null === $data || !is_array($data) ) {
057              throw new TokenResponseException('Unable to parse response.');
058          } elseif( isset($data['error'] ) ) {
059              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
060          }
061   
062          $token = new StdOAuth2Token();
063   
064   
065          $token->setAccessToken( $data['access_token'] );
066          // Github tokens evidently never expire...
067          $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
068          unset( $data['access_token'] );
069          $token->setExtraParams( $data );
070   
071          return $token;
072      }
073   
074      /**
075       * Used to configure response type -- we want JSON from github, default is query string format
076       *
077       * @return array
078       */
079      protected function getExtraOAuthHeaders()
080      {
081          return array('Accept' => 'application/json');
082      }
083   
084      /**
085       * Required for GitHub API calls.
086       *
087       * @return array
088       */
089      protected function getExtraApiHeaders()
090      {
091          return array('Accept' => 'application/vnd.github.beta+json');
092      }
093   
094      /**
095       * @return int
096       */
097      protected function getAuthorizationMethod()
098      {
099          return static::AUTHORIZATION_METHOD_QUERY_STRING;
100      }
101  }
102