Googleのpython apiを使用して融合テーブルのアクセス許可を変更することはできますか?アクセス許可と融合テーブルAPI
サービスアカウントを使用してテーブルを正常に作成できますが、個人用のGmailアカウントではなく、クライアントメール([email protected])の下にプライベートとしてテーブルが作成されます。
もしそうでない場合は、承認のためにServiceAccountsを使用しないでください。仕事は人間とのやりとりなしで実行する必要があります(つまり、oauth2をブラウザに貼り付けることはできません)。
完全を期すために、私は二つの方法
Fusion Table Python Client Library
def create_service(service='fusiontables',version='v2'):
credentials = ServiceAccountCredentials.from_json_keyfile_name(keyfile, scopes)
http = httplib2.Http()
credentials.authorize(http)
return discovery.build(service, version, http=http)
service = create_service()
service.table().insert(body={...}).execute()
http = httplib2.Http()
http = credentials.authorize(http)
http.request(
uri='https://www.googleapis.com/fusiontables/v2/tables',
method='POST',
headers={'Content-Type': 'application/json; charset=UTF-8'},
body=json.dumps({...}),
)
ANSWEでテーブルを作成しましたRの詳細(下記の@RodMcChesneyのおかげで)
私はDrive APIを使用しました。特に私はdrive client libraryを使用しました。
注:テーブルまたはサービスアカウントを作成する前に、あなたがそれを作成したら、コンソールに
ft_scope = 'https://www.googleapis.com/auth/fusiontables'
drive_scope = 'https://www.googleapis.com/auth/drive'
scopes = [ft_scope,drive_scope]
keyfile='sa_key.json'
# create drive and fusion table service (using method from above)
ft=create_service()
drive = create_service('drive')
# create table
ft.table().insert(body={...}).execute()
# get table id
id=drive.files().list().execute()['items'][0]['id']
# add permissions for 'anyone'
permission={'type': 'anyone','role': 'reader'}
drive.permissions().insert(fileId=id,body=permission).execute()
ありがとうございます!私はこのケースでDrive Permissions APIを使用する方法の明示的な詳細を質問に反映しています。 – brook