Google API Python client libraryを使用してサービスアカウントのJSONキーファイルからアクセストークンを生成し、それをリクエストのヘッダーに追加する必要があります。
ここであなたがピップを使用してGoogleのpython APIクライアントライブラリをインストールすることができrequests
from oauth2client.service_account import ServiceAccountCredentials
import requests
import json
import httplib2
scopes = [
'https://www.googleapis.com/auth/firebase',
'https://www.googleapis.com/auth/userinfo.email',
"https://www.googleapis.com/auth/cloud-platform"
]
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'/pathto/json_file.json', scopes)
headers = {"content-type": "application/json; charset=UTF-8"}
headers['Authorization'] = 'Bearer ' + credentials.get_access_token().access_token
firebase_url = "https://docs-examples.firebaseio.com/rest/saving-data/fireblog/users/alanisawesome/name.json"
data = {
"name": "Alan Turing",
"birthday": "June 23, 1912"}
requests.put(firebase_url, headers=headers, data=json.dumps(data).encode("utf-8"))
でそれを行う方法の例です:
pip install --upgrade google-api-python-client
私がアクセスしようとしたとき、私は拒否エラー403許可を得ますfirebaseデータベース。ドキュメントによるとうまくいくはずです。私の質問はこちらhttp://stackoverflow.com/questions/40810233です。私はあなたの助けに感謝します – bibscy