1

私は融合テーブル用のPythonラッパーを作成しています。 サービスにアクセスするためにGoogleサービスアカウントを使用することにしました。私のコードは次のとおりです。Googleサービスアカウントを使用する際の認証の問題。認証されていない使用の1日の制限を超えています。引き続き使用するにはサインアップが必要

import httplib2 
from googleapiclient.discovery import build 
from oauth2client.service_account import ServiceAccountCredentials 

scopes = ['https://www.googleapis.com/auth/fusiontables'] 
credentials = ServiceAccountCredentials.from_json_keyfile_name('__Remak APIS-37c11e21531ad.json', scopes) 

http = httplib2.Http() 

if not credentials.access_token: 
    credentials.refresh(http) 

service = build('fusiontables', 'v2', http=http) 


def test(): 
    table_id = '1esH-YayZegZH69VsiVBq0YK9hxgP-JWTCljRuQUZy' 

    print(service.query().sql(sql='SELECT * FROM {}'.format(table_id)).execute(http=http)) 


if __name__ == '__main__': 
    test() 

出力は次のようになります。私は確かに達していないために値幅制限がある理由は、このAPIを有効に

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/fusiontables/v2/query?alt=json&sql=SELECT+%2A+FROM+1esH-YayrtegZH6VsiVBq0YK9hxgP-JWTCljRuQUZy returned "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."> 

。私も同様の話題で答えを見つけようとしましたが、成功しませんでした。

事前に

をありがとう

答えて

0

は、最後にそれが仕事作っ: 一つの部分があった逃した: credentials.authorize(http) を今では、コード

OKらしいです:

import httplib2 

from googleapiclient.discovery import build 
from oauth2client.service_account import ServiceAccountCredentials 

scopes = ['https://www.googleapis.com/auth/fusiontables'] 
KEY = '__Remak APIS-a8cd56ca2b4e.json' 
credentials = ServiceAccountCredentials.from_json_keyfile_name(KEY,  scopes) 
http = httplib2.Http() 

credentials.authorize(http) 

if not credentials.access_token: 
    credentials.refresh(http) 

fusiontables = build('fusiontables', 'v2', http=http) 


def test(): 
    table_id = '1esH-YayZegZH97VsiVBq0YK9hxgP-JWTCljRuQUZy' 

    print(fusiontables.query().sql(sql='SELECT * FROM  {}'.format(table_id)).execute()) 


if __name__ == '__main__': 
    test() 
関連する問題