2

我正在尝试使用 OAUTH 更新 Fusion Tables 中的列。我可以很好地读取数据,没问题,但无法在第二个代码块中更新。它不断返回“HTTPError:HTTP 错误 401:需要登录”。帮助。

 #Get ROWID to update
    access_token = outhToken
    strSQL = "SELECT rowid FROM 15Uf_OWyeTKMDqfH-t9Jqeg_mNRz-CasBdKmYYSw WHERE Trail = '" + strTrailName + "'"
    request = urllib2.Request(url='https://www.google.com/fusiontables/api/query?%s' % (urllib.urlencode({'access_token': access_token,'sql': strSQL})))
    request_open = urllib2.urlopen(request)
    rowid = request_open.read()
    request_open.close()

    rows = rowid.split('\n');
    rowid = rows[1]
    iRowID = int(rowid)


    dateUpdated = datetime.now()- timedelta(minutes=300)


    #Update the status of this ROW
    response = urlfetch.fetch(
    url='https://www.google.com/fusiontables/api/query',
    payload = "sql=UPDATE 15Uf_OWyeTKMDqfH-t9Jqeg_mNRz-CasBdKmYYSw SET Status = " + str(Status)  + " WHERE ROWID  = '" + str(iRowID) + "'",
    method = urlfetch.POST,
    headers = {
    'Authorization': 'GoogleLogin auth=%s' % (access_token),
    'Content-Type': 'application/x-www-form-urlencoded'
    },
    deadline = 10).content
4

0 回答 0