wesleylima / django-rest-framework-firebase

Use Firebase to authenticate requests to your Django Rest Framework project
32 stars 14 forks source link

how to setup firebase config json #5

Open mreguly opened 5 years ago

mreguly commented 5 years ago

I am not able to setup your library on localhost. I have found firebase settings example here https://github.com/firebase/firebase-admin-python/blob/master/tests/data/service_account.json

On firebase they only gave me this as a config

"apiKey": "some_key"
"authDomain": "some_link",
"databaseURL": "some_link",
"projectId": "some_id",
"storageBucket": "some_link",
"messagingSenderId": "some_id",

After hours I still can't find the answer.

I also don't know where to put SHA1 or SHA256 from firebase app settings

I am getting this error:

from rest_framework.routers import DefaultRouter

File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/site-packages/rest_framework/routers.py", line 28, in from rest_framework import views File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/site-packages/rest_framework/views.py", line 19, in from rest_framework.schemas import DefaultSchema File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/site-packages/rest_framework/schemas/init.py", line 32, in authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES, File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/site-packages/rest_framework/settings.py", line 227, in getattr val = perform_import(val, attr) File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/site-packages/rest_framework/settings.py", line 172, in perform_import return [import_from_string(item, setting_name) for item in val] File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/site-packages/rest_framework/settings.py", line 172, in return [import_from_string(item, setting_name) for item in val] File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/site-packages/rest_framework/settings.py", line 183, in import_from_string module = import_module(module_path) File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/site-packages/rest_framework_firebase/authentication.py", line 16, in creds = credentials.Certificate(api_settings.FIREBASE_ACCOUNT_KEY_FILE) File "/home/guliver/.virtualenvs/djangox-3JrJ1blc/lib/python3.7/site-packages/firebase_admin/credentials.py", line 100, in init 'Caused by: "{0}"'.format(error)) ValueError: Failed to initialize a certificate credential. Caused by: "Incorrect padding"

wesleylima commented 5 years ago

It seems entering in each attribute directly in the config isn't working. However importing the whole config.json from firebase should work.

FIREBASE_AUTH = {
    'FIREBASE_ACCOUNT_KEY_FILE': 'path_to_your_credentials.json',
}