public function verify($action) { if ($action == "actionaccesstoken") { // provide the access token $client_id = $_REQUEST["client_id"]; $client_secret = $_REQUEST["client_secret"]; $code = $_REQUEST["code"]; $redirect_uri = $_REQUEST["redirect_uri"]; $grant_type = $_REQUEST["grant_type"]; // should be "authorization code" // validate the client $api = $this->lookupConsumer($client_id, $client_secret); if ($api) { $token = new DTOAuthToken($this->db->filter(array("type" => 0, "token" => $code, "status" => 1))); $token["consumer_id"] = $api["id"]; $token->updateToAccessToken($this->db); } exit("access_token={$token["token"]}"); } $this->access_token = $_REQUEST["access_token"]; //validate the token try { new DTOAuthToken($this->db->filter(array("token" => $this->access_token, "type" => 1, "status" => 0))); return true; } catch (Exception $e) { } return false; }
public function accessToken() { $tok_str = $this->provider->token; try { $token = new DTOAuthToken($this->db->where("type=0 AND token='{$tok_str}' AND status=1")); $token->updateToAccessToken($this->db); exit("oauth_token={$token["token"]}&oauth_token_secret={$token["secret"]}"); } catch (Exception $e) { throw new Exception("Unauthorized token ('{$tok_str}'). Request denied.", DT_ERR_UNAUTHORIZED_TOKEN); } }