Skip to content

Commit fc9bbbf

Browse files
authored
Make OAuth client_id optional in the google-services-desktop.json conversion script. (firebase#1223)
This change allows the generate_xml_from_google_services_json.py to succeed at generating the output when the OAuth "CLIENT_ID" is missing from the input. The OAuth client for an app is not always present, and not needed in most cases.
1 parent 02b1777 commit fc9bbbf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

generate_xml_from_google_services_json.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ def construct_google_services_json(xml_dict):
164164
'package_name': xml_dict['BUNDLE_ID']
165165
}
166166
},
167-
'oauth_client': [{
168-
'client_id': xml_dict['CLIENT_ID'],
169-
}],
170167
'api_key': [{
171168
'current_key': xml_dict['API_KEY']
172169
}],
@@ -182,6 +179,11 @@ def construct_google_services_json(xml_dict):
182179
'configuration_version':
183180
'1'
184181
}
182+
# OAuth client is optional, but include it if present.
183+
if 'CLIENT_ID' in xml_dict:
184+
json_struct['client'][0]['oauth_client'] = [{
185+
'client_id': xml_dict['CLIENT_ID'],
186+
}]
185187
return json.dumps(json_struct, indent=2)
186188
except KeyError as e:
187189
sys.stderr.write('Could not find key in plist file: [%s]\n' % (e.args[0]))

0 commit comments

Comments
 (0)