Skip to content

Commit 8921bc8

Browse files
committed
auth: service: don't forget to load json configs
1 parent a7a0ae9 commit 8921bc8

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

pydrive2/auth.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -571,22 +571,27 @@ def LoadClientConfigFile(self, client_config_file=None):
571571
pass # The service auth fields are not present, handling code can go here.
572572

573573
def LoadServiceConfigSettings(self):
574-
"""Loads client configuration from settings file.
574+
"""Loads client configuration from settings.
575575
:raises: InvalidConfigError
576576
"""
577-
for file_format in ["json", "pkcs12"]:
578-
config = f"client_{file_format}_file_path"
577+
configs = [
578+
"client_json_file_path",
579+
"client_json_dict",
580+
"client_json",
581+
"client_pkcs12_file_path",
582+
]
583+
584+
for config in configs:
579585
value = self.settings["service_config"].get(config)
580586
if value:
581587
self.client_config[config] = value
582588
break
583589
else:
584590
raise InvalidConfigError(
585-
"Either json or pkcs12 file path required "
586-
"for service authentication"
591+
f"One of {configs} is required for service authentication"
587592
)
588593

589-
if file_format == "pkcs12":
594+
if config == "client_pkcs12_file_path":
590595
self.SERVICE_CONFIGS_LIST.append("client_service_email")
591596

592597
for config in self.SERVICE_CONFIGS_LIST:

pydrive2/test/test_oauth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_10_ServiceAuthFromSavedCredentialsDictionary():
157157
def test_11_ServiceAuthFromJsonNoCredentialsSaving():
158158
client_json = os.environ[GDRIVE_USER_CREDENTIALS_DATA]
159159
settings = {
160-
"client_config_backend": "settings",
160+
"client_config_backend": "service",
161161
"service_config": {
162162
"client_json": client_json,
163163
},
@@ -174,7 +174,7 @@ def test_11_ServiceAuthFromJsonNoCredentialsSaving():
174174
def test_12_ServiceAuthFromJsonDictNoCredentialsSaving():
175175
client_json_dict = json.loads(os.environ[GDRIVE_USER_CREDENTIALS_DATA])
176176
settings = {
177-
"client_config_backend": "settings",
177+
"client_config_backend": "service",
178178
"service_config": {
179179
"client_json_dict": client_json_dict,
180180
},

0 commit comments

Comments
 (0)