medusa icon indicating copy to clipboard operation
medusa copied to clipboard

Error: Unknown authentication strategy "firebase.admin.medusa-auth-plugin_firebase"

Open ishaqkhattana opened this issue 1 year ago • 7 comments

Bug report

Describe the bug

I am trying to implement firebase auth in Medusa, for which I've setup a Firebase project and it works when using the Firebase SDK from another application. To implement firebase auth in a Medusa project, I've followed the following guide to the word: https://medusa-plugins.vercel.app/authentication/firebase (I've also installed the plugin yarn add medusa-plugin-auth)

System information

Medusa version (including plugins): Medusa v1.20.2, medusa-plugin-auth v1.10.3 Node.js version: v20.10.0 Database: PostgreSQL Operating system: MacOS Browser (if relevant):

Steps to reproduce the behavior

  1. Follow the guide: https://medusa-plugins.vercel.app/authentication/firebase
  2. Send a GET request to /admin/auth/firebase from Postman

Expected behavior

The request should return a 200 response with a session cookie set

Screenshots

Code snippets

medusa-config.js
{
    resolve: "medusa-plugin-auth",
    /** @type {import('medusa-plugin-auth').AuthOptions} */
    options: [
      {
        type: "firebase",
        // strict: "all", // or "none" or "store" or "admin"
        strict: "none",
        identifier: "firebase",
        credentialJsonPath: CredentialJsonPath,
        admin: {
          authPath: '/admin/auth/firebase',
          // expiresIn: 24 * 60 * 60 * 1000,
          verifyCallback: (container, decodedToken, strict) => {
          }
        },
        store: {
          // authPath: '/store/auth/firebase',
          // expiresIn: 24 * 60 * 60 * 1000,
          // verifyCallback: (container, decodedToken, strict) => {
          //    // implement your custom verify callback here if you need it
          // }
        }
      }
    ]
  },

Additional context

Add any other context about the problem here

ishaqkhattana avatar Feb 27 '24 21:02 ishaqkhattana

This is a config issue i believe, please check if you have set correctly Firebase Service Account Key file

xyzones avatar Feb 28 '24 10:02 xyzones

@xyzones Thank you for the prompt response, it was indeed a config issue. I've run into another issue, however, and would appreciate some more help. While following the code snippet in the plugin guide:

const firebaseLogin = async (token: string) => {
    await fetch(`${medusa_url}/${authPath}`, {
        method: 'GET',
        headers: {
            Authorization: `Bearer ${token}`
        },
        credentials: 'include'
    })
}

I'm getting a 401 unauthorized response. What is token here? I've tried the medusa JWT token retrieved from /auth/admin/token to no avail.

ishaqkhattana avatar Feb 29 '24 07:02 ishaqkhattana

@ishaqkhattana check the admin api docs please

xyzones avatar Feb 29 '24 08:02 xyzones

@ishaqkhattana did you find a solution to this (401 unauthorized response)

kevinrobert3 avatar Mar 12 '24 10:03 kevinrobert3

Facing the same problem here, Did someone get a fix?

balramxyadav avatar Aug 24 '24 11:08 balramxyadav