我尝试使用此api https://firebase.google.com/docs/projects/api/reference/rest/
设置身份验证:
credentials = ServiceAccountCredentials.from_p12_keyfile(
self.__service_account_email,
self.__path_to_p12,
scopes=['https://www.googleapis.com/auth/firebase'])
self.__service = build('firebase', 'v1beta1', credentials=credentials)
此方法正确有效
self._service.projects().androidApps().list(parent=self.project).execute()
self._service.projects().iosApps().list(parent=self.project).execute()
但是如果我使用getConfig
name = 'projects/{}/androidApps/{}/config'.format(self.project_id, app_id)
self._service.projects().androidApps().getConfig(name=name).execute()
我收到:
21:04:22 - oauth2client.client : INFO Refreshing access_token
21:04:23 - googleapiclient.discovery : INFO URL being requested: GET https://firebase.googleapis.com/v1beta1/projects/PROJECT_ID/iosApps/IOS_APP_ID/config?alt=json
21:04:24 - googleapiclient.http : WARNING Encountered 403 Forbidden with reason "forbidden"
21:04:24 - root : ERROR <HttpError 403 when requesting https://firebase.googleapis.com/v1beta1/projects/PROJECT_ID/iosApps/IOS_APP/config?alt=json returned "gaia_mint_verify::NO_MATCHING_SCOPES: Incoming scopes [(111700 25302 57500 1907 1914 53300 8305 145900 40100 70002 75101 28301 30401 706 1921 32722 713 107005 744 63913 15100 720 34204 22211 63906 32708 45701 727 9506 65300 8333 44103 57012 57019 8340 95500 44700 1433 21400 48900 95802 120001 8319 29400 53100 71600 70701 8312 1454 29414 35201 4400 29421 44300 330 92301 48500 90201 2732 44602 57300 25351 50800 50161 2904 56401 57005 25200 88210 741 62522 734 56805 62515 5703 54101 107001 755 103405 103412 15606 32729 7501 62508 75301 50210 62501 46600 66800 724 8323 49307 20403 68900 22208 731 32704 5605 121300 94201 64700 57503 82100 8309 40700 71200 4369 63924 97400 34200 28901 745 56302 103900 738 11508 27700 4320 49500 4471 8344 1300 11501 4464 86500 100002 25305 43000 90700 33101 8337 710 57008 703 57015 717 4306 8330 1918 34604 56404 26801 101101 62512 62505 77900 29403 2901 1700 499 29410 1405 1412 89601 29417 94001 52601 44110 4383 41901 29424 2729 752 70501 34400 49300 44001 320 62526 9338 15020 92600 3800 5700 56801 5707 62519 103401 57110 25354 99900 50041 50192 24606 45202 8341 103408 15603 95801 742 47110 137301 98000 8334 62525 22700 77200 5602 62518 8313 10002 29408 9700 310 62511 70700 41200 63926 29415 90207 77000 29422 56300 111706 721 92300 106600 32730 63919 41302 728 79500 714 140500 25352 32400 41400 20400 63912 735 8348 63905 32716 25201 36800 57020 77400 2775 352 45702 131501 1416 107000 18100 27803 4482 119400 70001 64400 7502 75300 53101 63933 89101 57501 83802 9328 8306 4401 34605 123807 73302 9500 2733 11600 21401 2912 113300 57006 2905 57013 22100 50600 63909 76600 65700 11509 34401 28621 61500 50400 59200 25306 8345 103404 64808 91900 103411 15010 81000 8338 25355 3601 59611 42000 33000 725 20404 13507 32705 22820 17103 29404 15600 70402 24600 57202 746 732 95805 11558 739 29418 47120 44100 89600 753 5209 65001 43201 63923 11551 14803 50042 57002 82001 57009 80800 56405 70500 68200 1441 21900 57016 4324 54600 700 1455 8324 62504 2765 1701 8331 4412 64000 8317 43001 87300 1413 6800 4440 26900 72400 8303 83100 212 25102 24800 4433 2923 135900 34606 29423 140501 799 15021 52301 70506 31400 99000 2906 50022 25353 750 50043 80700 103400 2713 107003 743 62524 103407 57400 86101 27804 62517 56803 22104 103414 55300 49302 141600 49000 65400 62510 67802 22701 15604 17100 91200 4321 80904 1905 63925 32706 26501 27400 63918 1912 9501 63904 8307 20401 32713 23000 711 8300 68901 49204 9357 1926 101500 718 40400 110100 19000 8342 2934 8349 95804 14800 100011 25307 25300 4300 63932 42008 62521 350 62514 25356 13501 29412 62507 2759 4420 53800 29419 95200 90203 123500 50162 2938 26701 1421 62500 69000 42900 90800 111701 85803 11559 213 63908 9315 34402 2731 26901 32000 2724 111501 46401 22101 4406 15011 4483 103403 28116 715 8332 153800 90600 15601 722 17104 94800 43002 15903 729 99800 8318 8304 63915 736 50106 10000 57003 111104 45000 61404 25303 57010 1435 49200 57017 1442 83201 8346 1902 70401 701 62900 47100 8339 22800 1909 4469 9600 107002 25101 57011 28100 23001 57018 88200 2928 7500 5702 50044 64402 108800 3100 46901 4301 80903 2907 30400 2749 32500 27401 66400 41500 122000 36700 113302 2763 4424 45700 9354 57004 733 4364 62523 43200 42006 62516 8343 103406 32900 15900 95803 1200 44106 8336 747 24100 103413 21501 8322 22702 68700 111300 25301 22105 66600 62502 4371 10011 754 56804 54100 102500 740 56200 32707 24300 1460 25357 64809 47600 1906 719 63917 1920 65701 19050 32714 712 63903 34203 11700 29420 77300 726 63910 61501 9316 15700 4312 81100 1436 1443 57000 2795 1903 28103 57007 44000 45201 56403 4333 1910 400 128900 57014 709 5706 34603 33100 8315 62513 44200 48400 99901 133100 35200 351 45703 62506 4421 8308 1415 2911 52600 70000 63700 1422 30101 86701 1429 28900 79000 63907 4382 25304 11511 32710 99002 26800 103402 32717 56800 2728 91600 8347 62520 103409 59620 50300 716 33300 1478 730 723 4340 737 42901 9309 93700 90206 42002 63914)] have no matching scopes in acceptable scopes [73301 35600]. Are you using HTTPS? [go/gaiamintssl]">
Traceback (most recent call last):
...
return self._service.projects().iosApps().getConfig(name=name).execute()
File "/.../venv/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "/.../venv/lib/python3.6/site-packages/googleapiclient/http.py", line 849, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://firebase.googleapis.com/v1beta1/projects/PROJEECT_ID/iosApps/APP_ID/config?alt=json returned "gaia_mint_verify::NO_MATCHING_SCOPES: Incoming scopes [(111700 25302 57500 1907 1914 53300 8305 145900 40100 70002 75101 28301 30401 706 1921 32722 713 107005 744 63913 15100 720 34204 22211 63906 32708 45701 727 9506 65300 8333 44103 57012 57019 8340 95500 44700 1433 21400 48900 95802 120001 8319 29400 53100 71600 70701 8312 1454 29414 35201 4400 29421 44300 330 92301 48500 90201 2732 44602 57300 25351 50800 50161 2904 56401 57005 25200 88210 741 62522 734 56805 62515 5703 54101 107001 755 103405 103412 15606 32729 7501 62508 75301 50210 62501 46600 66800 724 8323 49307 20403 68900 22208 731 32704 5605 121300 94201 64700 57503 82100 8309 40700 71200 4369 63924 97400 34200 28901 745 56302 103900 738 11508 27700 4320 49500 4471 8344 1300 11501 4464 86500 100002 25305 43000 90700 33101 8337 710 57008 703 57015 717 4306 8330 1918 34604 56404 26801 101101 62512 62505 77900 29403 2901 1700 499 29410 1405 1412 89601 29417 94001 52601 44110 4383 41901 29424 2729 752 70501 34400 49300 44001 320 62526 9338 15020 92600 3800 5700 56801 5707 62519 103401 57110 25354 99900 50041 50192 24606 45202 8341 103408 15603 95801 742 47110 137301 98000 8334 62525 22700 77200 5602 62518 8313 10002 29408 9700 310 62511 70700 41200 63926 29415 90207 77000 29422 56300 111706 721 92300 106600 32730 63919 41302 728 79500 714 140500 25352 32400 41400 20400 63912 735 8348 63905 32716 25201 36800 57020 77400 2775 352 45702 131501 1416 107000 18100 27803 4482 119400 70001 64400 7502 75300 53101 63933 89101 57501 83802 9328 8306 4401 34605 123807 73302 9500 2733 11600 21401 2912 113300 57006 2905 57013 22100 50600 63909 76600 65700 11509 34401 28621 61500 50400 59200 25306 8345 103404 64808 91900 103411 15010 81000 8338 25355 3601 59611 42000 33000 725 20404 13507 32705 22820 17103 29404 15600 70402 24600 57202 746 732 95805 11558 739 29418 47120 44100 89600 753 5209 65001 43201 63923 11551 14803 50042 57002 82001 57009 80800 56405 70500 68200 1441 21900 57016 4324 54600 700 1455 8324 62504 2765 1701 8331 4412 64000 8317 43001 87300 1413 6800 4440 26900 72400 8303 83100 212 25102 24800 4433 2923 135900 34606 29423 140501 799 15021 52301 70506 31400 99000 2906 50022 25353 750 50043 80700 103400 2713 107003 743 62524 103407 57400 86101 27804 62517 56803 22104 103414 55300 49302 141600 49000 65400 62510 67802 22701 15604 17100 91200 4321 80904 1905 63925 32706 26501 27400 63918 1912 9501 63904 8307 20401 32713 23000 711 8300 68901 49204 9357 1926 101500 718 40400 110100 19000 8342 2934 8349 95804 14800 100011 25307 25300 4300 63932 42008 62521 350 62514 25356 13501 29412 62507 2759 4420 53800 29419 95200 90203 123500 50162 2938 26701 1421 62500 69000 42900 90800 111701 85803 11559 213 63908 9315 34402 2731 26901 32000 2724 111501 46401 22101 4406 15011 4483 103403 28116 715 8332 153800 90600 15601 722 17104 94800 43002 15903 729 99800 8318 8304 63915 736 50106 10000 57003 111104 45000 61404 25303 57010 1435 49200 57017 1442 83201 8346 1902 70401 701 62900 47100 8339 22800 1909 4469 9600 107002 25101 57011 28100 23001 57018 88200 2928 7500 5702 50044 64402 108800 3100 46901 4301 80903 2907 30400 2749 32500 27401 66400 41500 122000 36700 113302 2763 4424 45700 9354 57004 733 4364 62523 43200 42006 62516 8343 103406 32900 15900 95803 1200 44106 8336 747 24100 103413 21501 8322 22702 68700 111300 25301 22105 66600 62502 4371 10011 754 56804 54100 102500 740 56200 32707 24300 1460 25357 64809 47600 1906 719 63917 1920 65701 19050 32714 712 63903 34203 11700 29420 77300 726 63910 61501 9316 15700 4312 81100 1436 1443 57000 2795 1903 28103 57007 44000 45201 56403 4333 1910 400 128900 57014 709 5706 34603 33100 8315 62513 44200 48400 99901 133100 35200 351 45703 62506 4421 8308 1415 2911 52600 70000 63700 1422 30101 86701 1429 28900 79000 63907 4382 25304 11511 32710 99002 26800 103402 32717 56800 2728 91600 8347 62520 103409 59620 50300 716 33300 1478 730 723 4340 737 42901 9309 93700 90206 42002 63914)] have no matching scopes in acceptable scopes [73301 35600]. Are you using HTTPS? [go/gaiamintssl]">
请告诉我,我哪里错了? 要么 Firebase v1beta1不稳定吗?
谢谢!
答案 0 :(得分:1)
我为此找到了新的python sdk
https://github.com/firebase/firebase-admin-python
设置:
import firebase_admin
cred = firebase_admin.credentials.Certificate(self.__path_to_json)
self.__project = firebase_admin.initialize_app(cred)
获取配置:
from firebase_admin import project_management
app = project_management.android_app(app_id, self._project)
config = app.get_config()
with open('google-services.json', 'w+') as f:
f.write(config)
有效!
答案 1 :(得分:1)
在撰写本文时,您可以使用范围https://www.googleapis.com/auth/cloud-platform
转到应用程序配置。文档中似乎有错误。