/** * Get token by ID */ public function getTokenById($id) { if ($id) { $record = Oauth_TokenRecord::model()->findById($id); if ($record) { $token = Oauth_TokenModel::populateModel($record); // will refresh token if needed try { if ($this->_refreshToken($token)) { // save refreshed token $this->saveToken($token); } } catch (\Exception $e) { OauthPlugin::log("OAuth.Debug - Couldn't refresh token\r\n" . $e->getMessage() . '\\r\\n' . $e->getTraceAsString(), LogLevel::Error, true); } return $token; } } }
/** * Get token by ID */ public function getTokenById($id) { if ($id) { $record = Oauth_TokenRecord::model()->findById($id); if ($record) { $token = Oauth_TokenModel::populateModel($record); // will refresh token if needed try { if ($this->_refreshToken($token)) { // save refreshed token $this->saveToken($token); } } catch (\Exception $e) { // todo: log // throw $e; // return null; } return $token; } } }
/** * Get token by ID */ public function getTokenByEncodedToken($encodedToken) { if ($encodedToken) { $conditions = 'encodedToken=:encodedToken'; $params = array(':encodedToken' => $encodedToken); $record = Oauth_TokenRecord::model()->find($conditions, $params); if ($record) { $token = Oauth_TokenModel::populateModel($record); // will refresh token if needed try { if ($this->refreshToken($token)) { // save refreshed token $this->saveToken($token); } } catch (\Exception $e) { // todo: log // throw $e; } return $token; } } }
public function getUserToken($handle, $userId = null) { Craft::log(__METHOD__, LogLevel::Info, true); $record = $this->_getTokenRecord($handle, null, $userId); if ($record) { return Oauth_TokenModel::populateModel($record); } return null; }