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

Commit 4551118

Browse files
Pinpoint: OTP operations
1 parent d92e732 commit 4551118

File tree

1 file changed

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

1 file changed

+79
-0
lines changed

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

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,82 @@ 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 actual 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 an actual SMS text message with the OTP code.
105+
There are alternative ways to retrieve the true OTP code as illustrated below:
106+
107+
{{< command >}}
108+
$ awslocal pinpoint send-otp-message \
109+
--application-id fff5a801e01643c18a13a763e22a8fbf \
110+
--send-otp-message-request-parameters '{
111+
"BrandName": "LocalStack Community",
112+
"Channel": "SMS",
113+
"DestinationIdentity": "+1224364860",
114+
"ReferenceId": "meetup2024",
115+
"OriginationIdentity": "+1123581321",
116+
"CodeLength": 6,
117+
"AllowedAttempts": 3,
118+
"ValidityPeriod": 2
119+
}'
120+
<disable-copy>
121+
{
122+
"MessageResponse": {
123+
"ApplicationId": "fff5a801e01643c18a13a763e22a8fbf"
124+
}
125+
}
126+
</disable-copy>
127+
{{< /command >}}
128+
129+
You can use the debug endpoint `/_aws/pinpoint/<application_id>/<reference_id>` to retrieve the OTP message details:
130+
131+
{{< command >}}
132+
$ curl http://localhost:4566/_aws/pinpoint/fff5a801e01643c18a13a763e22a8fbf/meetup2024 | jq .
133+
{
134+
"AllowedAttempts": 3,
135+
"BrandName": "LocalStack Community",
136+
"CodeLength": 6,
137+
"DestinationIdentity": "+1224364860",
138+
"OriginationIdentity": "+1123581321",
139+
"ReferenceId": "meetup2024",
140+
"ValidityPeriod": 2,
141+
"Attempts": 0,
142+
"ApplicationId": "fff5a801e01643c18a13a763e22a8fbf",
143+
"CreatedTimestamp": "2024-10-17T05:38:24.070Z",
144+
"Code": "655745"
145+
}
146+
{{< /command >}}
147+
148+
Futhermore, the OTP code is printed as an `INFO` level log message:
149+
150+
```text
151+
2024-10-17T11:08:24.044 INFO : OTP for application ID fff5a801e01643c18a13a763e22a8fbf reference ID meetup2024: 655745
152+
```
153+
154+
It can then verified using:
155+
156+
{{< command >}}
157+
$ awslocal pinpoint verify-otp-message \
158+
--application-id fff5a801e01643c18a13a763e22a8fbf \
159+
--verify-otp-message-request-parameters '{
160+
"ReferenceId": "meetup2024",
161+
"DestinationIdentity": "+1224364860",
162+
"Otp": "655745"
163+
}'
164+
<disable-copy>
165+
{
166+
"VerificationResponse": {
167+
"Valid": true
168+
}
169+
}
170+
</disable-copy>
171+
{{< /command >}}
172+
173+
When validating OTP codes, LocalStack accounts for the number of allowed attempts and the validity period.
174+
Unlike AWS, there is no lower limit for validity period.

0 commit comments

Comments
 (0)