Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit b696279

Browse files
Pinpoint: OTP operations (#1520)
1 parent 9d6ab2b commit b696279

File tree

1 file changed

+81
-0
lines changed
  • content/en/user-guide/aws/pinpoint

1 file changed

+81
-0
lines changed

content/en/user-guide/aws/pinpoint/index.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,84 @@ The following output would be retrieved:
9393
}
9494
}
9595
```
96+
97+
### OTP verification
98+
99+
The operations [`SentOTPMessage`](https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-otp.html#SendOTPMessage) and [`VerifyOTPMessage`](https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-verify-otp.html#VerifyOTPMessage) are used for one-time password (OTP) verification.
100+
101+
On production AWS, `SendOTPMessage` sends an SMS text message with the OTP code.
102+
The OTP can then be verified against the reference ID using `VerifyOTPMessage`
103+
104+
LocalStack however can not send real SMS text messages.
105+
Instead it provides alternative ways to retrieve the actual OTP code as illustrated below.
106+
107+
Begin by making a OTP request:
108+
109+
{{< command >}}
110+
$ awslocal pinpoint send-otp-message \
111+
--application-id fff5a801e01643c18a13a763e22a8fbf \
112+
--send-otp-message-request-parameters '{
113+
"BrandName": "LocalStack Community",
114+
"Channel": "SMS",
115+
"DestinationIdentity": "+1224364860",
116+
"ReferenceId": "liftoffcampaign",
117+
"OriginationIdentity": "+1123581321",
118+
"CodeLength": 6,
119+
"AllowedAttempts": 3,
120+
"ValidityPeriod": 2
121+
}'
122+
<disable-copy>
123+
{
124+
"MessageResponse": {
125+
"ApplicationId": "fff5a801e01643c18a13a763e22a8fbf"
126+
}
127+
}
128+
</disable-copy>
129+
{{< /command >}}
130+
131+
You can use the debug endpoint `/_aws/pinpoint/<application_id>/<reference_id>` to retrieve the OTP message details:
132+
133+
{{< command >}}
134+
$ curl http://localhost:4566/_aws/pinpoint/fff5a801e01643c18a13a763e22a8fbf/liftoffcampaign | jq .
135+
{
136+
"AllowedAttempts": 3,
137+
"BrandName": "LocalStack Community",
138+
"CodeLength": 6,
139+
"DestinationIdentity": "+1224364860",
140+
"OriginationIdentity": "+1123581321",
141+
"ReferenceId": "liftoffcampaign",
142+
"ValidityPeriod": 2,
143+
"Attempts": 0,
144+
"ApplicationId": "fff5a801e01643c18a13a763e22a8fbf",
145+
"CreatedTimestamp": "2024-10-17T05:38:24.070Z",
146+
"Code": "655745"
147+
}
148+
{{< /command >}}
149+
150+
The OTP code is also printed in an `INFO` level message in the LocalStack log output:
151+
152+
```text
153+
2024-10-17T11:08:24.044 INFO : OTP for application ID fff5a801e01643c18a13a763e22a8fbf reference ID liftoffcampaign: 655745
154+
```
155+
156+
Finally, the OTP code can be verified using:
157+
158+
{{< command >}}
159+
$ awslocal pinpoint verify-otp-message \
160+
--application-id fff5a801e01643c18a13a763e22a8fbf \
161+
--verify-otp-message-request-parameters '{
162+
"ReferenceId": "liftoffcampaign",
163+
"DestinationIdentity": "+1224364860",
164+
"Otp": "655745"
165+
}'
166+
<disable-copy>
167+
{
168+
"VerificationResponse": {
169+
"Valid": true
170+
}
171+
}
172+
</disable-copy>
173+
{{< /command >}}
174+
175+
When validating OTP codes, LocalStack checks for the number of allowed attempts and the validity period.
176+
Unlike AWS, there is no lower limit for validity period.

0 commit comments

Comments
 (0)