Skip to content

Commit f17cf09

Browse files
committed
allow configuration from django without .json file
1 parent b624f4d commit f17cf09

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

rest_framework_firebase/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
__title__ = 'djangorestframework-firebase-auth'
4-
__version__ = '0.1.3'
4+
__version__ = '0.1.4'
55
__author__ = 'Wesley Lima'
66
__license__ = 'MIT'
77
__copyright__ = 'Copyright 2018 Fan Retreat, Inc.'

rest_framework_firebase/authentication.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
BaseAuthentication, get_authorization_header
1313
)
1414

15-
# TODO: Support entering the keys individually later
16-
cred = credentials.Certificate(api_settings.FIREBASE_ACCOUNT_KEY_FILE)
17-
firebase = firebase_admin.initialize_app(cred)
15+
if api_settings.FIREBASE_ACCOUNT_KEY_FILE:
16+
creds = credentials.Certificate(api_settings.FIREBASE_ACCOUNT_KEY_FILE)
17+
else:
18+
creds = credentials.Certificate(api_settings.FIREBASE_CREDENTIALS)
19+
20+
firebase = firebase_admin.initialize_app(creds)
21+
1822

1923
class BaseFirebaseAuthentication(BaseAuthentication):
2024
"""

rest_framework_firebase/settings.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@
88

99
DEFAULTS = {
1010
'FIREBASE_ACCOUNT_KEY_FILE': '', # JSON formatted key file you get directly from firebase
11-
12-
# The credentials if you want to enter them in manually (not implemented)
13-
'FIREBASE_PRIVATE_KEY': None,
14-
'FIREBASE_PUBLIC_KEY': None,
15-
'FIREBASE_CLIENT_EMAIL': None,
11+
'FIREBASE_CREDENTIALS': {
12+
'type': "service_account",
13+
'project_id': "",
14+
'private_key_id': "",
15+
'private_key': "",
16+
'client_email': "",
17+
'client_id': "",
18+
'auth_uri': "https://accounts.google.com/o/oauth2/auth",
19+
'token_uri': "https://accounts.google.com/o/oauth2/token",
20+
'auth_provider_x509_cert_url': "https://www.googleapis.com/oauth2/v1/certs",
21+
'client_x509_cert_url': ""
22+
}, # the credentials in raw json form
23+
1624
'FIREBASE_CREATE_NEW_USER': True, # We'll make a new user if we get one that we don't have yet
1725

1826
'FIREBASE_AUTH_HEADER_PREFIX': "JWT",

0 commit comments

Comments
 (0)