adrien2p / medusa-plugins

A collection of awesome plugins for medusa :rocket:
https://medusa-plugins.vercel.app
MIT License
161 stars 46 forks source link

Issues with version 1.4.5 and 1.4.4 #79

Closed edihasaj closed 1 year ago

edihasaj commented 1 year ago

When I try to login with external providers I get this issue on the api:

1|api_v2   |
1|api_v2   | Please migrate your code to use AWS SDK for JavaScript (v3).
1|api_v2   | For more information, check the migration guide at https://a.co/7PzMCcy
1|api_v2   | (Use `node --trace-warnings ...` to show where the warning was created)
1|api_v2   | Error: Unknown authentication strategy "google.store.medusa-auth-plugin"
1|api_v2   |     at attempt (/home/debian/api_v2/node_modules/passport/lib/middleware/authenticate.js:193:39)
1|api_v2   |     at authenticate (/home/debian/api_v2/node_modules/passport/lib/middleware/authenticate.js:370:7)
1|api_v2   |     at Layer.handle [as handle_request] (/home/debian/api_v2/node_modules/express/lib/router/layer.js:95:5)
1|api_v2   |     at next (/home/debian/api_v2/node_modules/express/lib/router/route.js:144:13)
1|api_v2   |     at /home/debian/api_v2/node_modules/medusa-plugin-auth/core/passport/utils/auth-routes-builder.js:39:9
1|api_v2   |     at Layer.handle [as handle_request] (/home/debian/api_v2/node_modules/express/lib/router/layer.js:95:5)
1|api_v2   |     at next (/home/debian/api_v2/node_modules/express/lib/router/route.js:144:13)
1|api_v2   |     at Route.dispatch (/home/debian/api_v2/node_modules/express/lib/router/route.js:114:3)
1|api_v2   |     at Layer.handle [as handle_request] (/home/debian/api_v2/node_modules/express/lib/router/layer.js:95:5)
1|api_v2   |     at /home/debian/api_v2/node_modules/express/lib/router/index.js:284:15

this is my config:

  {
      resolve: "medusa-plugin-auth",
      options: {
          // Enable google OAuth 2
          google: {
              clientID: process.env.GOOGLE_CLIENT_ID | "",
              clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
              // Enable google OAuth 2 for the admin domain
              admin: {
                  callbackUrl: `${process.env.BACKEND_URL}/admin/auth/google/cb`,
                  failureRedirect: `${process.env.ADMIN_URL}/login`,
                  successRedirect: `${process.env.ADMIN_URL}/`,
                  //authPath: "/admin/auth/google",
                  //authCallbackPath: "/admin/auth/google/cb",
                  //expiresIn: 24 * 60 * 60 * 1000
              },
              // Enable google OAuth 2 for the store domain
              store: {
                  callbackUrl: `${process.env.BACKEND_URL}/store/auth/google/cb`,
                  failureRedirect: `${process.env.STORE_URL}/login`,
                  successRedirect: `${process.env.STORE_URL}/`,
                  authPath: "/store/auth/google",
                  authCallbackPath: "/store/auth/google/cb",
                  //expiresIn: 24 * 60 * 60 * 1000
              }
          },
          facebook: {
              clientID: process.env.FACEBOOK_CLIENT_ID,
              clientSecret: process.env.FACEBOOK_CLIENT_SECRET,
              // Enable facebook OAuth 2 for the admin domain
              admin: {
                  callbackUrl: `${process.env.BACKEND_URL}/admin/auth/facebook/cb`,
                  failureRedirect: `${process.env.ADMIN_URL}/login`,
                  successRedirect: `${process.env.ADMIN_URL}/`,
                  //authPath: "/admin/auth/facebook",
                  //authCallbackPath: "/admin/auth/facebook/cb",
                  //expiresIn: 24 * 60 * 60 * 1000
              },
              // Enable facebook OAuth 2 for the store domain
              store: {
                  callbackUrl: `${process.env.BACKEND_URL}/store/auth/facebook/cb`,
                  failureRedirect: `${process.env.STORE_URL}/login`,
                  successRedirect: `${process.env.STORE_URL}/`,
                  //authPath: "/store/auth/facebook",
                  //authCallbackPath: "/store/auth/facebook/cb",
                  //expiresIn: 24 * 60 * 60 * 1000
              }
          }
      }
  },

and these are my urls:

BACKEND_URL=api.myworkingapionproduction.com
STORE_URL=store.myworkingapionproduction.com
ADMIN_URL=api.myworkingapionproduction.com/app/

also the keys are set, before on earlier versions was working until some other step but now it fails at the beginning

I am using latest medusa version 1.11.1

adrien2p commented 1 year ago

When unknown strategy occurs it is always due to passport that is not the same version between medusa and the plugin and therefore both passport versions are installed and one is used in the plugin and the other one is used by medusa, or if the plugin does not load because of an error. hence why the error. BUt since you are using medusa 1.11.1 which install passport 0.6 and the plugin 1.4.5 expect the same version, i am unsure about why it happens. Can you check your node_modules to verify that there in the plugin node modules there is no passport install and that you have passport 0.6 installed please, another point to check is if your env are properly populated, if you log them just before the plugin options for example

edihasaj commented 1 year ago

ok, let me check and come back at you. Thank you Adrien