Esempio n. 1
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('https://oauth.reddit.com');
     }
 }
Esempio n. 2
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null, $apiVersion = "v3")
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true, $apiVersion);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('https://api.twitch.tv/kraken/');
     }
 }
 /**
  * Request access token
  *
  * This is the second step of oAuth authentication
  *
  * This implementation tries to abstract away differences between oAuth1 and oAuth2,
  * but might need to be overwritten for specific services
  *
  * @return bool
  */
 public function checkToken()
 {
     global $INPUT;
     if (is_a($this->oAuth, 'OAuth\\OAuth2\\Service\\AbstractService')) {
         /* oAuth2 handling */
         if (!$INPUT->get->has('code')) {
             return false;
         }
         $state = $INPUT->get->str('state', null);
         try {
             $this->oAuth->requestAccessToken($INPUT->get->str('code'), $state);
         } catch (TokenResponseException $e) {
             msg($e->getMessage(), -1);
             return false;
         }
     } else {
         /* oAuth1 handling */
         if (!$INPUT->get->has('oauth_token')) {
             return false;
         }
         $token = $this->storage->retrieveAccessToken($this->getServiceName());
         // This was a callback request from BitBucket, get the token
         try {
             $this->oAuth->requestAccessToken($INPUT->get->str('oauth_token'), $INPUT->get->str('oauth_verifier'), $token->getRequestTokenSecret());
         } catch (TokenResponseException $e) {
             msg($e->getMessage(), -1);
             return false;
         }
     }
     return true;
 }
Esempio n. 4
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
     if ($baseApiUri === null) {
         $this->baseApiUri = new Uri(self::API_URI_US);
     }
 }
Esempio n. 5
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
     if ($baseApiUri === null) {
         $this->baseApiUri = new Uri('https://getpocket.com/v3/');
     }
 }
Esempio n. 6
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('http://rest.bullhornstaffing.com/rest-services/');
     }
 }
Esempio n. 7
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null, $apiVersion = "")
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, false, $apiVersion);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('http://server.oauth2.nukeviet.vn/oauth2/resource');
     }
 }
Esempio n. 8
0
 public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri(static::BASE_URL . 'resource/');
     }
 }
Esempio n. 9
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('http://aimalyzer:8080/api/1.0/');
     }
 }
Esempio n. 10
0
 public function __construct(\OAuth\Common\Consumer\CredentialsInterface $credentials, \OAuth\Common\Http\Client\ClientInterface $httpClient, \OAuth\Common\Storage\TokenStorageInterface $storage, $scopes = array(), \OAuth\Common\Http\Uri\UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('https://www.readability.com/api/rest/v1/');
     }
 }
Esempio n. 11
0
 /**
  * {@inheritdoc}
  */
 public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
 {
     if (is_null($this->baseApiUri)) {
         $this->setBaseApiUri($this->storage->retrieveAccessToken($this->service()));
     }
     return parent::request($path, $method, $body, $extraHeaders);
 }
Esempio n. 12
0
 public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('https://api.paypal.com/v1/');
     }
 }
Esempio n. 13
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = [], UriInterface $baseApiUri = null, $apiVersion = "")
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, false, $apiVersion);
     $this->apiVersion = "v1";
     if (is_null($baseApiUri)) {
         $this->baseApiUri = new Uri(self::API_URL . $this->getApiVersionString());
     }
 }
 public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     $scopes = array();
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('https://sisilogin.testeveonline.com/oauth/');
     }
 }
Esempio n. 15
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
     $hlp = plugin_load('helper', 'oauth');
     $this->domain = $hlp->getConf('auth0-domain');
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri("https://{$this->domain}/");
     }
 }
Esempio n. 16
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     if (empty($scopes)) {
         $scopes = array(self::SCOPE_PUBLIC);
     }
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('https://www.strava.com/api/v3/');
     }
 }
Esempio n. 17
0
 /**
  * Returns a class constant from ServiceInterface defining the authorization method used for the API
  * Header is the sane default.
  *
  * @return int
  */
 protected function getAuthorizationMethod()
 {
     switch ($this->authorizationMethod) {
         case 'querystring':
             return static::AUTHORIZATION_METHOD_QUERY_STRING;
         case 'querystring2':
             return static::AUTHORIZATION_METHOD_QUERY_STRING_V2;
         case 'bearer':
             return static::AUTHORIZATION_METHOD_HEADER_BEARER;
     }
     return parent::getAuthorizationMethod();
 }
 /**
  * Request access token
  *
  * This is the second step of oAuth authentication
  *
  * This implementation tries to abstract away differences between oAuth1 and oAuth2,
  * but might need to be overwritten for specific services
  *
  * @return bool
  */
 public function checkToken()
 {
     global $INPUT;
     if (is_a($this->oAuth, 'OAuth\\OAuth2\\Service\\AbstractService')) {
         /* oAuth2 handling */
         if (!$INPUT->get->has('code')) {
             return false;
         }
         $state = $INPUT->get->str('state', null);
         try {
             $this->oAuth->requestAccessToken($INPUT->get->str('code'), $state);
         } catch (TokenResponseException $e) {
             msg($e->getMessage(), -1);
             return false;
         }
     } else {
         /* oAuth1 handling */
         if (!$INPUT->get->has('oauth_token')) {
             return false;
         }
         $token = $this->storage->retrieveAccessToken($this->getServiceName());
         // This was a callback request from BitBucket, get the token
         try {
             $this->oAuth->requestAccessToken($INPUT->get->str('oauth_token'), $INPUT->get->str('oauth_verifier'), $token->getRequestTokenSecret());
         } catch (TokenResponseException $e) {
             msg($e->getMessage(), -1);
             return false;
         }
     }
     $validDomains = $this->hlp->getValidDomains();
     if (count($validDomains) > 0) {
         $userData = $this->getUser();
         if (!$this->hlp->checkMail($userData['mail'])) {
             msg(sprintf($this->hlp->getLang("rejectedEMail"), join(', ', $validDomains)), -1);
             send_redirect(wl('', array('do' => 'login'), false, '&'));
         }
     }
     return true;
 }
Esempio n. 19
0
 /**
  * {@inheritdoc}
  */
 public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
 {
     $uri = $this->determineRequestUriFromPath($path, $this->baseApiUri);
     $uri->addToQuery('v', $this->apiVersionDate);
     return parent::request($uri, $method, $body, $extraHeaders);
 }
Esempio n. 20
0
 public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
 {
     $params = ['oauth_token' => 'qyprd3VVTi05a8Ukbv2DNO2Z2CP1CwflHHrGUiAOyPMQ1CTB', 'oauth_nonce' => $this->_nonce(), 'oauth_consumer_key' => $this->credentials->getConsumerId(), 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_timestamp' => time(), 'oauth_version' => '1.0'];
     $responseBody = $this->httpClient->retrieveResponse(new Uri(\Config::get('intuit.url') . $path), $params, $extraHeaders);
     dd($responseBody);
     array_walk($params, function (&$val, &$key) {
         $key = strtolower($key);
         $val = strtolower($key) . '=' . $val;
     });
     return parent::request($path, $method, $body, $extraHeaders);
 }
Esempio n. 21
0
 /**
  * {@inheritdoc}
  */
 public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
 {
     $uri = new Uri($this->baseApiUri . $path);
     $uri->addToQuery('v', $this->apiVersionDate);
     return parent::request($uri, $method, $body, $extraHeaders);
 }
Esempio n. 22
0
 /**
  * @param CredentialsInterface $credentials
  * @param ClientInterface $httpClient
  * @param TokenStorageInterface $storage
  * @param array $scopes
  * @param UriInterface $baseApiUri
  * @param Service $service
  */
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null, Service $service)
 {
     $this->service = $service;
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, $service->getValidateState());
 }
Esempio n. 23
0
 /**
  * {@inheritdoc}
  */
 public function request($path, array $body = [], $method = 'GET', array $extraHeaders = [])
 {
     $uri = $this->determineRequestUriFromPath($path);
     $uri->getQuery()->modify(['v' => $this->apiVersionDate]);
     return parent::request($uri, $body, $method, $extraHeaders);
 }
Esempio n. 24
0
 /**
  * {@inheritdoc}
  */
 public function getAuthorizationEndpoint()
 {
     $uri = parent::getAuthorizationEndpoint();
     $uri->getQuery()->modify(['access_type' => $this->accessType]);
     return $uri;
 }
Esempio n. 25
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null, $apiVersion = "")
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true, $apiVersion);
     if (null === $baseApiUri) {
         $this->baseApiUri = new Uri('https://graph.facebook.com' . $this->getApiVersionString() . '/');
     }
 }
Esempio n. 26
0
 /**
  * Retrieves and stores the OAuth2 access token after a successful authorization.
  *
  * @param string $code The access code from the callback.
  * @return TokenInterface $token
  * @throws TokenResponseException
  * @throws ErrorException
  * @throws InvalidStateException
  */
 public function requestAccessToken($code)
 {
     if (isset($this->state) && $this->service->getValidateState()) {
         if (!isset($_GET['state']) || !$this->state->validateId($_GET['state'])) {
             throw new InvalidStateException('The valid "state" argument required.');
         }
     }
     return parent::requestAccessToken($code);
 }
Esempio n. 27
0
 public function getAuthorizationUri(array $additionalParameters = [])
 {
     $state = uniqid();
     $this->storage->storeAuthorizationState($this->service(), $state);
     return parent::getAuthorizationUri(array_merge(['state' => $state], $additionalParameters));
 }
Esempio n. 28
0
 public function __construct(CredentialsInterface $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
 {
     parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
 }