[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Contains EveOnline class. 4 * PHP version 5.4. 5 * 6 * @author Michael Cummings <mgcummings@yahoo.com> 7 */ 8 9 namespace OAuth\OAuth2\Service; 10 11 use OAuth\Common\Consumer\CredentialsInterface; 12 use OAuth\Common\Http\Client\ClientInterface; 13 use OAuth\Common\Http\Exception\TokenResponseException; 14 use OAuth\Common\Http\Uri\Uri; 15 use OAuth\Common\Http\Uri\UriInterface; 16 use OAuth\Common\Storage\TokenStorageInterface; 17 use OAuth\Common\Token\TokenInterface; 18 use OAuth\OAuth2\Token\StdOAuth2Token; 19 20 /** 21 * Class EveOnline. 22 */ 23 class EveOnline extends AbstractService 24 { 25 public function __construct( 26 CredentialsInterface $credentials, 27 ClientInterface $httpClient, 28 TokenStorageInterface $storage, 29 $scopes = [], 30 ?UriInterface $baseApiUri = null 31 ) { 32 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); 33 34 if (null === $baseApiUri) { 35 $this->baseApiUri = new Uri('https://login.eveonline.com'); 36 } 37 } 38 39 /** 40 * Returns the authorization API endpoint. 41 * 42 * @return UriInterface 43 */ 44 public function getAuthorizationEndpoint() 45 { 46 return new Uri($this->baseApiUri . '/oauth/authorize'); 47 } 48 49 /** 50 * Returns the access token API endpoint. 51 * 52 * @return UriInterface 53 */ 54 public function getAccessTokenEndpoint() 55 { 56 return new Uri($this->baseApiUri . '/oauth/token'); 57 } 58 59 /** 60 * Parses the access token response and returns a TokenInterface. 61 * 62 * @param string $responseBody 63 * 64 * @return TokenInterface 65 */ 66 protected function parseAccessTokenResponse($responseBody) 67 { 68 $data = json_decode($responseBody, true); 69 70 if (null === $data || !is_array($data)) { 71 throw new TokenResponseException('Unable to parse response.'); 72 } elseif (isset($data['error_description'])) { 73 throw new TokenResponseException('Error in retrieving token: "' . $data['error_description'] . '"'); 74 } elseif (isset($data['error'])) { 75 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); 76 } 77 78 $token = new StdOAuth2Token(); 79 $token->setAccessToken($data['access_token']); 80 $token->setLifeTime($data['expires_in']); 81 82 if (isset($data['refresh_token'])) { 83 $token->setRefreshToken($data['refresh_token']); 84 unset($data['refresh_token']); 85 } 86 87 unset($data['access_token'], $data['expires_in']); 88 89 $token->setExtraParams($data); 90 91 return $token; 92 } 93 94 /** 95 * {@inheritdoc} 96 */ 97 protected function getAuthorizationMethod() 98 { 99 return static::AUTHORIZATION_METHOD_HEADER_BEARER; 100 } 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |