Skip to content

Project doest not build with payload-plugin-oauth(^0.3.1) #9

@rohitttttt

Description

@rohitttttt

Payload does not build with payload-plugin-oauth.

Using below code in payloadconfig.ts

export default buildConfig({
serverURL: process.env.SERVER_URL,//'http://localhost:3000',
admin: {
user: Users.slug,
},
plugins: [
// Replace this plugin with our Custom Plugin for Authentication..
oAuthPlugin({
clientID: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
authorizationURL: ${process.env.OAUTH_SERVER}/oauth2/authorize,
tokenURL: ${process.env.OAUTH_SERVER}/oauth2/token,
callbackURL: ${process.env.SERVER_URL}/oauth2/callback,
async userinfo(accessToken) {
console.log('inside user info');
const userDetailToken = decodeToken(accessToken);
if(userDetailToken && userDetailToken.unique_name && userDetailToken?.name){
return {
sub: userDetailToken?.oid || 'test',
name: userDetailToken?.name || userDetailToken?.given_name,
email: userDetailToken?.unique_name || userDetailToken?.upn,

    }
  }
  },
}),

],
collections: [TodoLists, Users],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
})

Getting 2 errors.
1)ClientID is not able to found in oauth plugin. For work around i have downloaded the code from github and added missing types in types.ts file and this issue got fixed but again when i ran npm run build it got stuck.
image

2)In oauth Plugin application is not able to pick the value from env file during npm run build. To fix this issue i have passed the hardcoded value then after that my npm run build got stuck. It seems there is issue with this library when i am building my payload cms project.

image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions