thgh / payload-plugin-oauth

Add oAuth sign in to your Payload CMS site
MIT License
89 stars 16 forks source link

unable to build payload #21

Closed beewhoo closed 8 months ago

beewhoo commented 10 months ago

upon updating to 2.2 I am unable to build when passing databaseUri

when passing empty string(databaseUri:"") it is able to build, but fails if db uri is given.

it doesn't show any failure, just hang on generate:types, and help would be appreciated! thank you in advance!

when passing db uri


payload-cms:generate:types: [21:40:59] INFO (payload): Starting Payload...
payload-cms:generate:types: [21:40:59] INFO (payload): Compiling TS types for Collections and Globals...
payload-cms:generate:types: [21:41:00] INFO (payload): Types written to /Users/beewhoo/Documents/capsule/studio/packages/shared-types/payload.ts

when empty string

[21:52:10] INFO (payload): Starting Payload...
[21:52:10] INFO (payload): Compiling TS types for Collections and Globals...
[21:52:11] INFO (payload): Types written to /Users/beewhoo/Documents/capsule/studio/packages/shared-types/payload.ts
npm verb exit 0
npm info ok 

here is my setup

  oAuthPlugin({
      databaseUri: process.env.MONGODB_URI,
      scope: "",
      clientID: process.env.CLIENT_ID,
      clientSecret: process.env.CLIENT_SECRET,
      authorizationURL: process.env.OAUTH_SERVER + "/oauth/authorize",
      tokenURL: process.env.OAUTH_SERVER + "/oauth/token",
      callbackURL: process.env.CALLBACK_URL,
      successRedirect: process.env.FRONTEND_URL,
      async userinfo(accessToken) {
        const options = {
          headers: {
            Authorization: `Bearer ${accessToken}`,
          },
        };

        try {
          const response = await axios.get(
            process.env.OAUTH_SERVER + "/capsule/v1/users/me",
            options
          );
          const user = response.data;

          return {
            email: user.email,
          };
        } catch (error) {
          console.error(error);
        }
      },
    } as oAuthPluginOptions)
stillalive commented 8 months ago

@beewhoo did you ever find a solution for this?

beewhoo commented 8 months ago

@beewhoo did you ever find a solution for this?

are you on the latest version? yup after this change it solved issue