Skip to content
Bitzsoft.Integrationsbitzsoft.integrations

Reference

腾讯天御验证码

腾讯天御 TCaptcha 包的 TencentOptions 配置字段、CaptchaAppId/AppSecretKey 鉴权与使用示例。

Last updated

包信息

属性
NuGet 包Bitzsoft.Integrations.Captcha.Tencent
Provider IDtencent
鉴权SecretId + SecretKey + CaptchaAppId(TC3-HMAC-SHA256)
版本天御 TCaptcha

配置字段(TencentOptions)

字段类型必填默认值说明
SecretIdstring腾讯云 SecretId
SecretKeystring腾讯云 SecretKey
CaptchaAppIdlong0验证码应用 CaptchaAppId
AppSecretKeystring验证码应用 AppSecretKey
Regionstringap-guangzhou地域
Endpointstringcaptcha.tencentcloudapi.com验证码服务端点
ScriptUrlstring腾讯 CDN前端 SDK 脚本地址
TimeoutTimeSpan30sHTTP 请求超时
HttpClientNamestringTencentCaptchaProvider命名 HttpClient

配置示例

{
"Captcha": {
"Tencent": {
"SecretId": "AKIDxxxxxxxx",
"SecretKey": "your-secret-key",
"CaptchaAppId": 1234567890,
"AppSecretKey": "your-app-secret-key"
}
}
}

DI 注册

builder.Services.AddBitzsoftTencentCaptcha(builder.Configuration.GetSection("Captcha:Tencent"));

使用示例

public class TencentCaptchaService(ICaptchaProvider captcha)
{
public async Task<CaptchaResult<CaptchaVerification>> VerifyAsync(string ticket, string randstr, string userIp)
{
return await captcha.VerifyAsync(new CaptchaVerifyRequest
{
Ticket = ticket,
Randstr = randstr,
UserIp = userIp,
});
}
}

已知限制

  • AppSecretKey 是验证码应用的密钥(在腾讯云验证码控制台获取),与 SecretKey 是不同的密钥。
  • CaptchaAppIdlong 类型(非 string)。

相关

100%

滚轮或按钮缩放 · 放大后拖动画面 · 双击切换 100% / 200%