Podio API - 项目任务同步期间令牌无效

Podio API - Invalid token during project tasks sync

我们当前在尝试获取新任务时收到此 400 错误:

{"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http:\/\/api.podio.com\/task","query_string":"completed=true&completed_on=-5d&fields=completed_on&limit=100&offset=0&sort_by=rank&sort_desc=false&space=3798819","method":"GET"},"error_description":"Invalid token '(files,tags,votes)'","error":"invalid_value"}

请注意,我们不会将其用于内部目的,而是设置了一个允许任务同步和完成的集成。

我们正在循环对所有 space 任务进行分页:

get('/task', { space: project_link.remote_id, sort_by: 'rank', limit: limit, offset: offset, sort_desc: false, completed: completed, fields: 'completed_on' })

编辑:

def sync_project(project_link)
  existing_remote_ids = _synced_remote_task_ids(project_link.link_id)
  synced_project_ids = []
  [{completed: false}, {completed: true}].each do |params|
    offset = 0
    loop do
      tasks, next_offset = tasks_page_for_project(project_link: project_link, offset: offset, **params)
      tasks.each do |task|
        remote_task = map_podio_task(task, project_link.link_id)
        _process_task(remote_task)
        synced_project_ids << remote_task[:id].to_s
      end
      offset = next_offset
      break unless next_offset
    end
  end
  _mark_tasks_deleted(existing_remote_ids - synced_project_ids)
end

def tasks_page_for_project(project_link:, offset:, completed: false)
  next_offset = nil
  limit = 100
  params = { space: project_link.remote_id, sort_by: 'rank', limit: limit, offset: offset, sort_desc: false, completed: completed, fields: 'completed_on' }
  params[:completed_on] = '-5d' if completed
  tasks = get('/task', params)
  if tasks.size == limit
    next_offset = offset + limit
  end
  return tasks, next_offset
rescue TaskSync::ProjectRemovedError => ex
  raise TaskSync::ProjectRemovedError.new(self, project_link.remote_id), ex.message
rescue TaskSync::TemporaryNetworkError => ex
  ex.project_id = project_link.remote_id
  raise ex
end

def service
  check_token
  @service ||= build_client(href, 'Authorization' => "OAuth2 #{token[:token]}")
end

def authorization
  params = {
    grant_type: 'refresh_token',
    client_id: TaskSync.config[:podio][:client_id],
    client_secret: TaskSync.config[:podio][:client_secret],
    refresh_token: token[:refresh_token]
  }

  build_client 'https://podio.com/oauth/token', { 'Content-Type' => 'application/x-www-form-urlencoded' }, params
end

def href
  'https://api.podio.com'
end

并且此错误仅发生在单个客户端上。

你能告诉我们这个错误是什么意思吗?它是与 OAuth 相关还是与其他东西有关?

谢谢!

你没有提到你使用的是什么编程语言这里是我在PHP上写的一个例子:

require_once 'podio/PodioAPI.php'; //podio library

error_log("validate triggerd");

$client_id = 'your client Id';
$client_secret = 'your client secret';
$app_id = 'your app id';
$app_token = 'your app token';

Podio::setup($client_id, $client_secret);
// Turn on debugging
Podio::$debug = true;

// Authenticate the app
Podio::authenticate('app', array('app_id' => $app_id, 'app_token' => $app_token));

并获取您的物品:

$tasks = PodioTask::get_all( $attributes = array() );

感谢您报告跑道文档中发现的问题。这是误导性的(更新的文档已经发布)。

completed_on 字段的格式为 YYYY-MM-DD-YYYY-MM-DD
例如。对于 2017 年 6 月完成的所有任务:2017-06-01-2017-06-30