AWS Cognito OAuth Provider

Authenticate using AWS Cognito OAuth provider.


Callback or Redirect URL pattern

https://example.com/api/{name}/oauth/callback/cognito




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

export default buildConfig({
  // --- rest of the config
  plugins: [
    // --- rest of the plugins
    authPlugin({
      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,
        }),
      ],
    }),
  ],
});

        

Args

  • client_id:

Type: string

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

Optional: No.


ts
            {
  client_id: "";
}

        

  • client_secret:

Type: string

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

Optional: No.


ts
            {
  client_secret: "";
}

        

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: "";
}

        

Returns

provider OIDCProviderConfig

::


CognitoAuthConfig


CognitoAuthConfig.params:

Type: Record<string, string>

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

Optional: Yes.

ts
            {
  params: {
    // additional parameters
  }
}

        

::