AWS Cognito OAuth Provider

Authenticate using AWS Cognito OAuth provider.


src/payload.config.ts
ts
            import { buildConfig } from "payload/config";
import { adminAuthPlugin } from "payload-auth-plugin";
import { CognitoAuthProvider } from "payload-auth-plugin/providers";

export default buildConfig({
  // --- rest of the config
  plugins: [
    // --- rest of the plugins
    adminAuthPlugin({
      providers: [
        CognitoAuthProvider({
          client_id: process.env.PROVIDER_CLIENT_ID as string,
          client_secret: process.env.PROVIDER_CLIENT_SECRET as string,
          domain: process.env.COGNITO_DOMAIN as string,
          region: process.env.COGNITO_REGION as string,
        }),
      ],
    }),
  ],
});

        

Parameters


Returns

provider OIDCProviderConfig


CognitoAuthConfig

CognitoAuthConfig.client_id:

Type: string

Description: client_id is a string generated by Cognito to identify your Payload app.

Optional: No.

ts
            {
  client_id: "";
}

        

CognitoAuthConfig.client_secret:

Type: string

Description: client_secret is a private key generated by Cognito to authenticate your Payload app.

Optional: No.

ts
            {
  client_secret: "";
}

        

CognitoAuthConfig.domain:

Type: string

Description: domain of the AWS Cognito user pool.

Optional: No.

ts
            {
  domain: "";
}

        

CognitoAuthConfig.region:

Type: string

Description: region of the AWS Cognito user pool.

Optional: No.

ts
            {
  region: "";
}

        

CognitoAuthConfig.params:

Type: Record<string, string>

Description: params any additional parameters to pass to the IDP for authorization.

Optional: Yes.

ts
            {
  params: {
    // additional parameters
  }
}