OTP 验证系统
OTP 验证系统提供一个 API,包括 发送 OTP 和 验证 OTP,以将 OTP 验证应用于游戏。
URL
认证方法
要实现OTP发送系统提供的API,需要一个授权令牌(API KEY)。在您的游戏在AppCenter注册后,认证令牌会自动发放。遵循JWT(JSON Web Token: https://jwt.io)规范的授权令牌没有过期时间限制,因此可以继续使用此令牌。
发送 OTP
发送 OTP 短信
如果 OTP 短信不是由 OTP 直接发送而是由您自己发送,您可以通过回调接收发送 OTP 短信所需的信息。在 Hive 控制台 > 通知 > 短信 OTP > 发送信息设置 中,选择 直接发送,以下数据将以 JSON 格式发送到注册的回调 URL 的请求体中。请参阅 回调请求示例 和 回调数据。
//sample 1
curl --location 'https://otp.qpyou.cn/otp/send'
--header 'Authorization: Bearer AUTH_TOKNE_VALUE'
--header 'Topic: testTopicName'
--header 'Content-Type: application/json'
--data '{
"to" : "01012345678",
"toCountryNo" : "82",
"lang" : "ko"
}'
//sample 2
curl --location 'https://otp.qpyou.cn/otp/send'
--header 'Authorization: Bearer AUTH_TOKNE_VALUE'
--header 'Topic: testTopicName'
--header 'Content-Type: application/json'
--data '{
"to" : "01012345678",
"toCountryNo" : "82",
"lang" : "ko",
"retry" : true,
"lookup" : true
}'
{
"otp" : "123456",
"provider" : "YOUR SMS PROVIDER",
"expiry" : "2022-07-20T15:18:06.885195100+09:00[Asia/Seoul]"
}
回调示例
curl --location 'https://{your_callback_url}'
--header 'Content-Type: application/json'
--data '{
"to":"01012345678",
"toCountryNo":"82",
"lang":"en",
"retry":null,
"lookup":false,
"serviceName":"LocalTest",
"otp":"809881",
"provider":"DIRECTSEND",
"expiry":"2024-06-26T11:36:29.680680500+09:00[Asia/Seoul]",
"expiryTimestamp":1719369389680
}'
回调数据通知
发送 OTP 邮件
//sample
curl --location 'https://otp.qpyou.cn/otp/email/send'
--header 'Authorization: bearer AUTH_TOKEN_VALUE'
--header 'Topic: testTopicName'
--header 'Content-Type: application/json'
--data-raw '{
"sender" : "staging-no-reply@withhive.com",
"senderName" : "YOUR SERVICE NAME",
"receiver" : "com2us@com2us.com",
"subject" : "OTP EMAIL SEND",
"lang" : "ko"
}'
{
"otp" : "123456",
"expiry" : "2022-07-20T15:19:19.305116+09:00[Asia/Seoul]"
}
验证 OTP
// sample 1
curl --location 'https://otp.qpyou.cn/otp/verify'
--header 'Authorization: bearer AUTH_TOKEN_VALUE'
--header 'Topic: testTopicName'
--header 'Content-Type: application/json'
--data '{
"toCountryNo" : "82",
"to" : "01036012891",
"otp" : "123456"
}'
//sample 2
curl --location 'https://otp.qpyou.cn/otp/verify'
--header 'Authorization: bearer AUTH_TOKEN_VALUE'
--header 'Topic: testTopicName'
--header 'Content-Type: application/json'
--data-raw '{
"receiver" : "com2us@com2us.com",
"otp" : "123456"
}'
{
"result" : true (or false)
}