You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/events/cognito-user-pool.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,6 +140,45 @@ function handler(event, context, callback) {
140
140
}
141
141
```
142
142
143
+
### PreTokenGeneration Trigger
144
+
145
+
The PreTokenGeneration trigger supports multiple lambda versions for enhanced token customization:
146
+
147
+
```yml
148
+
functions:
149
+
preTokenGenerationV1:
150
+
handler: preToken.handler
151
+
events:
152
+
- cognitoUserPool:
153
+
pool: MyUserPool
154
+
trigger: PreTokenGeneration
155
+
# No lambdaVersion = V1_0 behavior (ID token customization only)
156
+
157
+
preTokenGenerationV2:
158
+
handler: preToken.handler
159
+
events:
160
+
- cognitoUserPool:
161
+
pool: MyUserPool
162
+
trigger: PreTokenGeneration
163
+
lambdaVersion: V2_0 # ID + Access token customization
164
+
165
+
preTokenGenerationV3:
166
+
handler: preToken.handler
167
+
events:
168
+
- cognitoUserPool:
169
+
pool: MyUserPool
170
+
trigger: PreTokenGeneration
171
+
lambdaVersion: V3_0 # Includes M2M client-credentials grants
172
+
```
173
+
174
+
**Lambda Version Support:**
175
+
176
+
- `V1_0` (default): ID token customization only
177
+
- `V2_0`: ID and access token customization
178
+
- `V3_0`: Includes machine-to-machine (M2M) client-credentials grants
179
+
180
+
**NOTE:** V2_0 and V3_0 require your user pool to be on the Essentials or Plus feature plan, as documented [by AWS](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html).
181
+
143
182
### Custom Message Trigger Handlers
144
183
145
184
For custom messages, you will need to check `event.triggerSource` type inside your handler function:
0 commit comments