swensonhe / strapi-firebase-auth

MIT License
20 stars 8 forks source link

Unable to setup properly #64

Open Sandeep28633 opened 2 months ago

Sandeep28633 commented 2 months ago

Cannot read properties of undefined (reading 'auth') at .../node_modules/@swensonhe/strapi-plugin-firebase-auth/server/services/userService.js:8:71

image (1)
tothang commented 2 months ago

@Sandeep28633 Did you use firebaseConfig to set up ? If yes. Please download your serviceAccountKey.json copy all value from that file and paste to the input that will help to solve the issue

Sandeep28633 commented 2 months ago

@tothang yes Followed all the steps

tothang commented 2 months ago

@tothang yes Followed all the steps

download your serviceAccountKey.json copy all value from that file and paste to the input instead inputing firebaseConfig. That will solve your issue. Check for how to download https://clemfournier.medium.com/how-to-get-my-firebase-service-account-key-file-f0ec97a21620

Sandeep28633 commented 2 months ago
image

SHould I paste here. ?

tothang commented 2 months ago

@Sandeep28633 Yep. please paste all item in serviceAccountKey.json to that input and come back here with the result

Sandeep28633 commented 2 months ago

@tothang everything seems to be working fine, except firebase auth users are not getting synced with strapi users.

when I am creating user from firebase console, user is reflecting on firebase plugin strapi but not in user section, can you please help me with that

tothang commented 2 months ago

@Sandeep28633 user need to login by strapi for syncing with users table of strapi. That is correct behaviour . You cannot just add user on firebase console and expect that user getting synced with strapi users. If you really wana do that let''s write a script to synced data from firebase users to your users tables strapi

Sandeep28633 commented 2 months ago

@tothang thanks for your quick response, I want my frontend users to access the authenticated data from strapi, If users sign up using Firebase, then how will they access the strapi data that is not publicly available? I just wanted to understand what's the use of this plugin in a general sense. My first impression while reading the docs was that users will be synced automatically to the strapi.

tothang commented 2 months ago

@Sandeep28633 go to strapi. Setting > Role > Public and look for auth firebase then enable. You can call api login to strapi by firebase token

bhartendu27 commented 2 months ago

@Sandeep28633 This issue is being caused by incorrect documentation, you will need the serviceAccount json file from your firebase console. After that COPY THE CONTENTS OF SERVICE ACCOUNT JSON FILE (NOT example firebase code, as shown in the docs) and paste it in firebase configuration inside strapi. Hope this helps. PS: don't forget to enable the firebase authentication token validation route inside the public role