adrien2p / medusa-plugins

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

hi i am not able to implement oauth2 #163

Closed shubhamchoudhary-2003 closed 5 months ago

shubhamchoudhary-2003 commented 6 months ago

i am using oauth2 from discord

When I try it with the admin, it redirects me to the admin page. However, when I use it for the storefront, it gets stuck on this page for hours Screenshot 2024-05-23 091320

this is my plugin file

` {
    resolve: "medusa-plugin-auth",
    /** @type {import('medusa-plugin-auth').AuthOptions} */
    options: [
      {
        type: "oauth2",
        strict: "store",
        identifier: "oauth2",
        authorizationURL: OAuth2AuthorizationURL,
        tokenURL: OAuth2TokenURL,
        clientID: OAuth2ClientId,
        clientSecret: OAuth2ClientSecret,
        scope: OAuth2Scope.split(","),
        store: {
          callbackUrl: `${BACKEND_URL}/store/auth/oauth2/cb`,
          failureRedirect: `${STORE_URL}/login`,
          successRedirect: `${STORE_URL}/`,
        },
      },
    ],
  },
`

and this is env

const BACKEND_URL = process.env.BACKEND_URL || "http://localhost:9000";
const ADMIN_URL = process.env.ADMIN_URL || "http://localhost:7001";
const STORE_URL = process.env.STORE_URL || "http://localhost:3000";

const OAuth2AuthorizationURL =process.env.OAUTH2_AUTHORIZATION_URL ||"https://discord.com/api/oauth2/authorize";
const OAuth2TokenURL =process.env.OAUTH2_TOKEN_URL || "https://discord.com/api/oauth2/token";
const OAuth2ClientId = process.env.OAUTH2_CLIENT_ID || "";
const OAuth2ClientSecret =process.env.OAUTH2_CLIENT_SECRET || "";
const OAuth2Scope = process.env.OAUTH2_SCOPE || "identify,email,guilds";

and in storefront

     <a
        type="button"
        href={`${process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL}/store/auth/oauth2/`}
        className="text-white bg-[#4285F4] hover:bg-[#4285F4]/90 focus:ring-4 focus:outline-none focus:ring-[#4285F4]/50 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-[#4285F4]/55 mr-2 mb-2"
      >
        Login with Discord
      </a>

HERE ARE MORE IMAGES FOR CONTEXT

Screenshot 2024-05-23 085803 Screenshot 2024-05-23 091320 Screenshot 2024-05-23 091330 Screenshot 2024-05-23 091349

adrien2p commented 5 months ago

Could you provide your logs please? alos, one thought, depending what discord provides you with you might need to implement the parseProfile function in your config to return something the plugin can consume

shubhamchoudhary-2003 commented 5 months ago

IT IS THERE FOR LIFETIME

Screenshot (351)

adrien2p commented 5 months ago

Have you looked at what i ve answered you please? Also, i am talking about the server logs not the client... plus, this type of message with all uppercase is not very welcome here please be respectful