ASANA API和Access-Control- *标头

时间:2012-05-12 22:31:40

标签: api access-control asana

我正在编写一些代码来从浏览器调用Asana API。从浏览器发出的XDR请求都以调用OPTIONS来获取Access-Control- *标头开头,但Asana服务器似乎没有响应它们:

Request URL:https://app.asana.com/api/1.0/users?opt_pretty=true&opt_fields=name,email
Request Method:OPTIONS
Status Code:404 Object Not Found
Request Headers:
  Accept:*/*
  Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
  Access-Control-Request-Headers:origin, authorization, accept
  Access-Control-Request-Method:GET
  Connection:keep-alive
  Host:app.asana.com
  Origin:null
  User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1129.0 Safari/536.11

Query String Parameters:
  opt_pretty:true
  opt_fields:name,email

Response Headers:
  Content-Length:82
  Content-Type:application/json
  Date:Sat, 12 May 2012 22:23:19 GMT
  Server:nginx/0.7.67
  ...

响应标头应包含以下内容:

Access-Control-Allow-Headers: Accept, Authorization, Content-Type
Access-Control-Allow-Methods: GET,PUT,POST,DELETE
Access-Control-Allow-Origin: *

或者在请求API时我有什么遗漏?

1 个答案:

答案 0 :(得分:0)

(我在Asana工作)

Asana API目前不会返回这些标头,因为它不支持OAuth,也无法安全地验证来自客户端的请求。仅为经过身份验证的客户端返回这些标头是安全的,否则该服务将对跨站点脚本攻击开放。 OAuth位于将来支持的功能列表中。