Пример #1
0
 public function getOAuthAccessorTokenKey(TokenKey $tokenKey, ProviderInfo $provInfo)
 {
     $provKey = new ProviderKey();
     $provKey->setGadgetUri($tokenKey->getGadgetUri());
     $provKey->setServiceName($tokenKey->getServiceName());
     //AccesorInfo
     $result = $this->getOAuthAccessorProviderKey($provKey, $provInfo);
     //TokenInfo
     $accessToken = $this->getTokenInfo($tokenKey);
     if ($accessToken != null) {
         // maybe convert into methods
         $result->getAccessor()->accessToken = $accessToken->getAccessToken();
         $result->getAccessor()->tokenSecret = $accessToken->getTokenSecret();
     }
     return $result;
 }
 private function buildTokenKey()
 {
     $tokenKey = new TokenKey();
     // need to URLDecode so when comparing with the ProviderKey it goes thought
     $tokenKey->setGadgetUri(urldecode($this->authToken->getAppUrl()));
     $tokenKey->setModuleId($this->authToken->getModuleId());
     $tokenKey->setServiceName($this->requestParams->getServiceName());
     $tokenKey->setTokenName($this->requestParams->getTokenName());
     // At some point we might want to let gadgets specify whether to use OAuth
     // for the owner, the viewer, or someone else. For now always using the
     // owner identity seems reasonable.
     $tokenKey->setUserId($this->authToken->getOwnerId());
     return $tokenKey;
 }
 /**
  *
  * @return TokenKey 
  */
 private function buildTokenKey()
 {
     $tokenKey = new TokenKey();
     // need to URLDecode so when comparing with the ProviderKey it goes thought
     $tokenKey->setGadgetUri(urldecode($this->authToken->getAppUrl()));
     $tokenKey->setModuleId($this->authToken->getModuleId());
     $tokenKey->setAppId($this->authToken->getAppId());
     $tokenKey->setServiceName($this->requestParams->getServiceName());
     $tokenKey->setTokenName($this->requestParams->getTokenName());
     // We should always use the current viewer id as a token key. Using the owner id
     // would mean, that a private access token (with possible write access to the api)
     // could be accessable to other viewers that are visiting the gadget of another
     // owner
     $tokenKey->setUserId($this->authToken->getViewerId());
     return $tokenKey;
 }
 /**
  * Retrieve an OAuthAccessor that is ready to sign OAuthMessages.
  *
  * @param tokenKey information about the gadget retrieving the accessor.
  *
  * @return an OAuthAccessorInfo containing an OAuthAccessor (whic can be
  *         passed to an OAuthMessage.sign method), as well as httpMethod and
  *         signatureType fields.
  */
 public function getOAuthAccessor(TokenKey $tokenKey, $ignoreCache)
 {
     $gadgetUri = $tokenKey->getGadgetUri();
     if (empty($gadgetUri)) {
         throw new OAuthStoreException("found empty gadget URI in TokenKey");
     }
     $getUserId = $tokenKey->getUserId();
     if (empty($getUserId)) {
         throw new OAuthStoreException("found empty userId in TokenKey");
     }
     $gadgetSpec = $this->specFactory->getGadgetSpecUri($gadgetUri, $ignoreCache);
     $provInfo = $this->getProviderInfo($gadgetSpec, $tokenKey->getServiceName());
     return $this->store->getOAuthAccessorTokenKey($tokenKey, $provInfo);
 }