使用承载令牌授权标头在PUT和POST上禁止BaseCamp API

时间:2014-10-08 03:56:47

标签: oauth-2.0 omniauth basecamp

GET请求正常工作。

我正在使用omniauth-basecamp和restclient:

resource = RestClient::Resource.new(
  'https://basecamp.com/27xxxxx/api/v1',
  headers: {
    user_agent: 'MyApp (me@example.com',
    authorization: "Bearer #{my_token}",
    content_type: "application/json"
  }
)

resource['/projects/7213xxx/todos/129851xxx.json'].get # => 200 OK
resource['/projects/7213xxx/todos/129851xxx.json'].put(content: 'Hello!') # => 403 FORBIDDEN

1 个答案:

答案 0 :(得分:0)

问题是有效负载没有被序列化为json,所以它是表单编码的。

   payload = {content: 'Hello!!'}.to_json
   resource['/projects/7213xxx/todos/129851xxx.json'].put(payload) # => 200 OK

想知道响应是否应该是Bad Request而不是Forbidden。