我无法找到此信息,我可以从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"
}
访问类型是否与此有关?
答案 0 :(得分:0)
我已经能够通过删除参数中的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
}