django谷歌日历v3插入事件 - 解析错误

时间:2013-05-28 13:35:34

标签: python django rest google-calendar-api

我没有直接使用客户端库而是使用REST。我成功创建了谷歌登录。我保存了用户的access_token。当我尝试创建新事件并将其插入用户日历时,我使用access_token(这里的代码是硬编码的)。这是我的代码

def google_get_list(request):
    parser = httplib2.Http()
    uri = "https://www.googleapis.com/calendar/v3/calendars/primary/events?key={YOUR_API_KEY}"\
        .format(YOUR_API_KEY='AIzaSyD_Axx9SGH0Y71xxxxxxxxxxxxxxxxxxxxx')
    params = urllib.urlencode({
        "summary": "Test Calendar",
    })
    headers = {'Content-Type': 'application/json', 
               'Authorization':  'Bearer ya29.AHES6ZQdFo8IXu5gAns8qEiyLbcbZxxxxxxxxxxxxxxxxxxxxxxxxxx',
               'X-JavaScript-User-Agent':  'Google APIs Explorer'
               }
    resp, content = parser.request(uri, method='POST', body=params, headers=headers)
    print content
    return HttpResponseRedirect('/')

收到的内容(打印)是

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "parseError",
    "message": "Parse Error"
   }
  ],
  "code": 400,
  "message": "Parse Error"
 }
} 

任何帮助?

0 个答案:

没有答案