[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ -> Microsoft.php (source)

   1  <?php
   2  
   3  namespace OAuth\OAuth2\Service;
   4  
   5  use OAuth\OAuth2\Token\StdOAuth2Token;
   6  use OAuth\Common\Http\Exception\TokenResponseException;
   7  use OAuth\Common\Http\Uri\Uri;
   8  use OAuth\Common\Consumer\CredentialsInterface;
   9  use OAuth\Common\Http\Client\ClientInterface;
  10  use OAuth\Common\Storage\TokenStorageInterface;
  11  use OAuth\Common\Http\Uri\UriInterface;
  12  
  13  class Microsoft extends AbstractService
  14  {
  15      const SCOPE_BASIC = 'wl.basic';
  16      const SCOPE_OFFLINE = 'wl.offline_access';
  17      const SCOPE_SIGNIN = 'wl.signin';
  18      const SCOPE_BIRTHDAY = 'wl.birthday';
  19      const SCOPE_CALENDARS = 'wl.calendars';
  20      const SCOPE_CALENDARS_UPDATE = 'wl.calendars_update';
  21      const SCOPE_CONTACTS_BIRTHDAY = 'wl.contacts_birthday';
  22      const SCOPE_CONTACTS_CREATE = 'wl.contacts_create';
  23      const SCOPE_CONTACTS_CALENDARS = 'wl.contacts_calendars';
  24      const SCOPE_CONTACTS_PHOTOS = 'wl.contacts_photos';
  25      const SCOPE_CONTACTS_SKYDRIVE = 'wl.contacts_skydrive';
  26      const SCOPE_EMAILS = 'wl.emails';
  27      const SCOPE_EVENTS_CREATE = 'wl.events_create';
  28      const SCOPE_MESSENGER = 'wl.messenger';
  29      const SCOPE_PHONE_NUMBERS = 'wl.phone_numbers';
  30      const SCOPE_PHOTOS = 'wl.photos';
  31      const SCOPE_POSTAL_ADDRESSES = 'wl.postal_addresses';
  32      const SCOPE_SHARE = 'wl.share';
  33      const SCOPE_SKYDRIVE = 'wl.skydrive';
  34      const SCOPE_SKYDRIVE_UPDATE = 'wl.skydrive_update';
  35      const SCOPE_WORK_PROFILE = 'wl.work_profile';
  36      const SCOPE_APPLICATIONS = 'wl.applications';
  37      const SCOPE_APPLICATIONS_CREATE = 'wl.applications_create';
  38  
  39      public function __construct(
  40          CredentialsInterface $credentials,
  41          ClientInterface $httpClient,
  42          TokenStorageInterface $storage,
  43          $scopes = array(),
  44          UriInterface $baseApiUri = null
  45      ) {
  46          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
  47  
  48          if (null === $baseApiUri) {
  49              $this->baseApiUri = new Uri('https://apis.live.net/v5.0/');
  50          }
  51      }
  52  
  53      /**
  54       * {@inheritdoc}
  55       */
  56      public function getAuthorizationEndpoint()
  57      {
  58          return new Uri('https://login.live.com/oauth20_authorize.srf');
  59      }
  60  
  61      /**
  62       * {@inheritdoc}
  63       */
  64      public function getAccessTokenEndpoint()
  65      {
  66          return new Uri('https://login.live.com/oauth20_token.srf');
  67      }
  68  
  69      /**
  70       * {@inheritdoc}
  71       */
  72      public function getAuthorizationMethod()
  73      {
  74          return static::AUTHORIZATION_METHOD_QUERY_STRING;
  75      }
  76  
  77      /**
  78       * {@inheritdoc}
  79       */
  80      protected function parseAccessTokenResponse($responseBody)
  81      {
  82          $data = json_decode($responseBody, true);
  83  
  84          if (null === $data || !is_array($data)) {
  85              throw new TokenResponseException('Unable to parse response.');
  86          } elseif (isset($data['error'])) {
  87              throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
  88          }
  89  
  90          $token = new StdOAuth2Token();
  91          $token->setAccessToken($data['access_token']);
  92          $token->setLifetime($data['expires_in']);
  93  
  94          if (isset($data['refresh_token'])) {
  95              $token->setRefreshToken($data['refresh_token']);
  96              unset($data['refresh_token']);
  97          }
  98  
  99          unset($data['access_token']);
 100          unset($data['expires_in']);
 101  
 102          $token->setExtraParams($data);
 103  
 104          return $token;
 105      }
 106  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1