【问题标题】:Insert data in Fusion Tables using RefreshToken使用 RefreshToken 在 Fusion Tables 中插入数据
【发布时间】:2017-03-18 21:42:48
【问题描述】:

我无法找到此信息,我可以从 Google Fusion Table 中获取数据,但我无法在未传递访问令牌的情况下更新该表。谷歌文档非常混乱,查找这些信息很复杂,Python 代码示例已经过时。

requests.post(url_api, params={'access_token': <access_token>, 
sql': "INSERT INTO " +  table_id + " (address) VALUES ('Test text')",
'key': fusion_api})

我收到 401 错误,我正在使用刷新令牌从 Google OAuth API 获取访问令牌。

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "authError",
    "message": "Invalid Credentials",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Invalid Credentials"
 }
}

我通过 Google API 检查了我的令牌:

{
 "issued_to": "XXXX.apps.googleusercontent.com",
 "audience": "XXXX.apps.googleusercontent.com",
 "scope": "https://www.googleapis.com/auth/fusiontables",
 "expires_in": 3600,
 "access_type": "offline"
}

访问类型是否与此有关?

【问题讨论】:

    标签: python oauth-2.0 token google-fusion-tables


    【解决方案1】:

    我已经能够通过删除参数中的 fusion_api 键来解决这个问题:

    headers = {'Authorization': bearer_str ,'Content-Type': 'application/json', 'Host': 'www.googleapis.com'}
    params = {
        'sql':"SELECT * FROM " + table_id,
        'key': fusion_api
    }
    

    headers = {'Authorization': bearer_str ,'Content-Type': 'application/json', 'Host': 'www.googleapis.com'}
    params = {
        'sql':"SELECT * FROM " + table_id
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 2014-10-11
      相关资源
      最近更新 更多