import{_ as d,c as r,a as o,b as t,d as e,e as l,w as a,r as i,o as p}from"./app-CDdN0tOz.js";const c={};function u(D,s){const n=i("RouteLink");return p(),r("div",null,[s[35]||(s[35]=o('<h1 id="v-voucher-验证" tabindex="-1"><a class="header-anchor" href="#v-voucher-验证"><span>v_voucher 验证</span></a></h1><h2 id="简述" tabindex="-1"><a class="header-anchor" href="#简述"><span>简述</span></a></h2><p>当同一接口在短时间内被同一用户/IP/UA多次请求或异常时, 会触发风控, 如接口返回 <code>code</code> 为 <code>-352</code> 即 <code>风控校验失败</code>, 同时 <code>data</code> 中出现 <code>v_voucher</code> 字段, 响应头出现 <code>x-bili-gaia-vvoucher</code></p><p><code>v_voucher</code> 结构为字符串 <code>voucher_</code> 尾随一串以 <code>-</code> 为分隔符的小写 UUID</p><p><code>v_voucher</code> 可用于申请 captcha 验证码, 若无意外发生, 根据验证结果使用 <code>validate</code> 接口获取 <code>grisk_id</code> 作为被风控接口的 <code>gaia_vtoken</code> 与 Cookie 中的 <code>x-bili-gaia-vtoken</code>, 即可恢复正常访问</p>',5)),t("p",null,[s[2]||(s[2]=e("若该情况出现在使用 Wbi 签名的接口中, 建议先检查 Wbi 签名是否正确. 若已检查 Wbi 签名或无需签名, 检查请求头中 ")),s[3]||(s[3]=t("code",null,"User-Agent",-1)),s[4]||(s[4]=e()),s[5]||(s[5]=t("code",null,"Referer",-1)),s[6]||(s[6]=e(" 是否正常, 以及 ")),s[7]||(s[7]=t("code",null,"Cookie",-1)),s[8]||(s[8]=e(" 中 ")),l(n,{to:"/docs/misc/sign/bili_ticket.html"},{default:a(()=>s[0]||(s[0]=[t("code",null,"bili_ticket",-1)])),_:1,__:[0]}),s[9]||(s[9]=e()),l(n,{to:"/docs/misc/buvid3_4.html"},{default:a(()=>s[1]||(s[1]=[t("code",null,"b_nut",-1),e(),t("code",null,"buvid3",-1),e(),t("code",null,"buvid4",-1)])),_:1,__:[1]}),s[10]||(s[10]=e(" 等是否存在. 使用 captcha 是最后的选择, 因为 captcha 验证需要用户操作"))]),s[36]||(s[36]=t("p",null,[e("参见 "),t("a",{href:"https://github.com/SocialSisterYi/bilibili-API-collect/issues/1067",target:"_blank",rel:"noopener noreferrer"},"#1067")],-1)),s[37]||(s[37]=t("p",null,[t("strong",null,"注意: 不是所有风控都可以使用本方式通过 captcha 解决")],-1)),s[38]||(s[38]=t("h2",{id:"操作流程",tabindex:"-1"},[t("a",{class:"header-anchor",href:"#操作流程"},[t("span",null,"操作流程")])],-1)),t("ol",null,[s[28]||(s[28]=o(`<li><p>快速以不正确的姿势请求接口, 直到返回 <code>v_voucher</code> 字段如下. 若 <code>data</code> 中没有 <code>v_voucher</code> 字段, 则检查响应头 <code>x-bili-gaia-vvoucher</code></p><div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-json"><span class="line"><span style="color:#D4D4D4;">{</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;code&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">-352</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;message&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;风控校验失败&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;ttl&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;data&quot;</span><span style="color:#D4D4D4;">: {</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;v_voucher&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;voucher_84a8c3ce-33f5-4551-9552-9c6b13aa7938&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">  }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></li>`,1)),t("li",null,[t("p",null,[s[12]||(s[12]=t("a",{href:"#%E4%BB%8E-v_voucher-%E7%94%B3%E8%AF%B7-captcha"},[e("请求 "),t("code",null,"register"),e(" 接口")],-1)),s[13]||(s[13]=e(", 请求体传入 ")),s[14]||(s[14]=t("code",null,"csrf",-1)),s[15]||(s[15]=e(" 及 ")),s[16]||(s[16]=t("code",null,"v_voucher",-1)),s[17]||(s[17]=e(", 该接口返回与 ")),l(n,{to:"/docs/login/login_action/#%E7%94%B3%E8%AF%B7captcha%E9%AA%8C%E8%AF%81%E7%A0%81"},{default:a(()=>s[11]||(s[11]=[e("申请captcha验证码")])),_:1,__:[11]}),s[18]||(s[18]=e(" 部分相同, 记录此处返回的 ")),s[19]||(s[19]=t("code",null,"token",-1)),s[20]||(s[20]=e()),s[21]||(s[21]=t("code",null,"challenge",-1))])]),t("li",null,[t("p",null,[s[23]||(s[23]=e("按照 ")),l(n,{to:"/docs/login/login_action/#%E9%AA%8C%E8%AF%81captcha%E9%AA%8C%E8%AF%81%E7%A0%81"},{default:a(()=>s[22]||(s[22]=[e("验证captcha验证码")])),_:1,__:[22]}),s[24]||(s[24]=e(" 进行验证, 记下验证结果的 ")),s[25]||(s[25]=t("code",null,"validate",-1)),s[26]||(s[26]=e(" 与 ")),s[27]||(s[27]=t("code",null,"seccode",-1))])]),s[29]||(s[29]=o('<li><p><a href="#%E4%BB%8E%E9%AA%8C%E8%AF%81%E7%BB%93%E6%9E%9C%E8%8E%B7%E5%8F%96-grisk_id">请求 <code>validate</code> 接口</a>, 请求体传入 <code>challenge</code> <code>token</code> <code>validate</code> <code>seccode</code> <code>csrf</code>, 该接口返回 <code>grisk_id</code> 即 <code>gaia_vtoken</code> 与 <code>x-bili-gaia-vtoken</code></p></li><li><p>重新请求原接口, 原 URL 参数加入 <code>gaia_vtoken</code>, Cookie 加入 <code>x-bili-gaia-vtoken</code>, 即恢复正常</p></li>',2))]),s[39]||(s[39]=t("h2",{id:"接口列表",tabindex:"-1"},[t("a",{class:"header-anchor",href:"#接口列表"},[t("span",null,"接口列表")])],-1)),s[40]||(s[40]=t("h3",{id:"从-v-voucher-申请-captcha",tabindex:"-1"},[t("a",{class:"header-anchor",href:"#从-v-voucher-申请-captcha"},[t("span",null,"从 v_voucher 申请 captcha")])],-1)),s[41]||(s[41]=t("blockquote",null,[t("p",null,"https://api.bilibili.com/x/gaia-vgate/v1/register")],-1)),t("p",null,[s[31]||(s[31]=e("注: 同一有效 ")),s[32]||(s[32]=t("code",null,"v_voucher",-1)),s[33]||(s[33]=e(" 只能请求一次, 请求完毕请立即 ")),l(n,{to:"/docs/login/login_action/#%E8%BF%9B%E8%A1%8C%E9%AA%8C%E8%AF%81"},{default:a(()=>s[30]||(s[30]=[e("进行验证")])),_:1,__:[30]}),s[34]||(s[34]=e(" 防止过期失效"))]),s[42]||(s[42]=o(`<p><em>请求方式: POST</em></p><p><strong>正文参数(application/x-www-form-urlencoded):</strong></p><table><thead><tr><th>参数名</th><th>类型</th><th>内容</th><th>必要性</th><th>备注</th></tr></thead><tbody><tr><td>csrf</td><td>str</td><td>CSRF Token (位于 Cookie 的 bili_jct)</td><td>非必要</td><td></td></tr><tr><td>v_voucher</td><td>str</td><td>v_voucher</td><td>必要</td><td></td></tr></tbody></table><p><strong>JSON回复:</strong></p><p>根对象:</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>code</td><td>num</td><td>返回值</td><td>0：成功<br>100000: 验证码获取失败</td></tr><tr><td>message</td><td>str</td><td>错误信息</td><td>默认为 0</td></tr><tr><td>ttl</td><td>num</td><td>1</td><td></td></tr><tr><td>data</td><td>obj</td><td>信息本体</td><td></td></tr></tbody></table><p><code>data</code> 对象:</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>type</td><td>str</td><td>验证码类型</td><td>目前只有 <code>geetest</code></td></tr><tr><td>token</td><td>str</td><td>验证码 token</td><td>用于验证</td></tr><tr><td>geetest</td><td>obj</td><td>极验信息</td><td>若为 null 则说明该风控无法通过 captcha 解除</td></tr><tr><td>biliword</td><td>null</td><td></td><td></td></tr><tr><td>phone</td><td>null</td><td></td><td></td></tr><tr><td>sms</td><td>null</td><td></td><td></td></tr></tbody></table><p><code>geetest</code> 对象:</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>gt</td><td>str</td><td>极验id</td><td>一般为固定值</td></tr><tr><td>challenge</td><td>str</td><td>极验KEY</td><td>由B站后端产生用于人机验证</td></tr></tbody></table><p><strong>示例:</strong></p><p>假设此处 <code>v_voucher</code> 为 <code>voucher_ecca35e6-36da-4f38-bd84-b3f420ea08c1</code></p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-shell"><span class="line"><span style="color:#DCDCAA;">curl</span><span style="color:#569CD6;"> -X</span><span style="color:#CE9178;"> POST</span><span style="color:#CE9178;"> &quot;https://api.bilibili.com/x/gaia-vgate/v1/register&quot;</span><span style="color:#D7BA7D;"> \\</span></span>
<span class="line"><span style="color:#D4D4D4;">--data-urlencode </span><span style="color:#CE9178;">&quot;v_voucher=voucher_ecca35e6-36da-4f38-bd84-b3f420ea08c1&quot;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><details><summary>查看响应示例:</summary><div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-json"><span class="line"><span style="color:#D4D4D4;">{</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;code&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;message&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;0&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;ttl&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;data&quot;</span><span style="color:#D4D4D4;">: {</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;type&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;geetest&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;token&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;e7abdb050c3d4609979f1685137e3bc0&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;geetest&quot;</span><span style="color:#D4D4D4;">: {</span></span>
<span class="line"><span style="color:#9CDCFE;">      &quot;challenge&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;85118f8714875ca4c6d5641bb0ce9ddf&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">      &quot;gt&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;ac597a4506fee079629df5d8b66dd4fe&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">    },</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;biliword&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#569CD6;">null</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;phone&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#569CD6;">null</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;sms&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#569CD6;">null</span></span>
<span class="line"><span style="color:#D4D4D4;">  }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h2 id="从验证结果获取-grisk-id" tabindex="-1"><a class="header-anchor" href="#从验证结果获取-grisk-id"><span>从验证结果获取 grisk_id</span></a></h2><blockquote><p>https://api.bilibili.com/x/gaia-vgate/v1/validate</p></blockquote><p><em>请求方式: POST</em></p><p><strong>正文参数(application/x-www-form-urlencoded):</strong></p><table><thead><tr><th>参数名</th><th>类型</th><th>内容</th><th>必要性</th><th>备注</th></tr></thead><tbody><tr><td>csrf</td><td>str</td><td>CSRF Token (位于 Cookie 的 bili_jct)</td><td>非必要</td><td>若登陆则必要</td></tr><tr><td>challenge</td><td>str</td><td>验证码 challenge</td><td>必要</td><td></td></tr><tr><td>token</td><td>str</td><td>验证码 token</td><td>必要</td><td></td></tr><tr><td>validate</td><td>str</td><td>验证结果 validate</td><td>必要</td><td></td></tr><tr><td>seccode</td><td>str</td><td>验证结果 seccode</td><td>必要</td><td></td></tr></tbody></table><p><strong>JSON回复:</strong></p><p>根对象:</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>code</td><td>num</td><td>返回值</td><td>0：成功<br>-111: csrf 校验失败<br>100003: 验证码过期</td></tr><tr><td>message</td><td>str</td><td>错误信息</td><td>默认为 0</td></tr><tr><td>ttl</td><td>num</td><td>1</td><td></td></tr><tr><td>data</td><td>obj</td><td>信息本体</td><td></td></tr></tbody></table><p><code>data</code> 对象:</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>is_valid</td><td>num</td><td>验证结果</td><td>1：验证成功</td></tr><tr><td>grisk_id</td><td>str</td><td>gaia_vtoken</td><td>用于恢复正常访问</td></tr></tbody></table><p><strong>示例:</strong></p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-shell"><span class="line"><span style="color:#DCDCAA;">curl</span><span style="color:#569CD6;"> -X</span><span style="color:#CE9178;"> POST</span><span style="color:#CE9178;"> &quot;https://api.bilibili.com/x/gaia-vgate/v1/validate&quot;</span><span style="color:#D7BA7D;"> \\</span></span>
<span class="line"><span style="color:#D4D4D4;">--data-urlencode </span><span style="color:#CE9178;">&quot;challenge=e4fcb337b8c0427b56320f97e1064210&quot;</span><span style="color:#D7BA7D;"> \\</span></span>
<span class="line"><span style="color:#D4D4D4;">--data-urlencode </span><span style="color:#CE9178;">&quot;csrf=xxxxxxxxxxxxxxx&quot;</span><span style="color:#D7BA7D;"> \\</span></span>
<span class="line"><span style="color:#D4D4D4;">--data-urlencode </span><span style="color:#CE9178;">&quot;seccode=360f7b9cf75c74c68fbb7475416d0e0d|jordan&quot;</span><span style="color:#D7BA7D;"> \\</span></span>
<span class="line"><span style="color:#D4D4D4;">--data-urlencode </span><span style="color:#CE9178;">&quot;token=0e1e58bdff3d4b8aa298e346fed07eeb&quot;</span><span style="color:#D7BA7D;"> \\</span></span>
<span class="line"><span style="color:#D4D4D4;">--data-urlencode </span><span style="color:#CE9178;">&quot;validate=360f7b9cf75c74c68fbb7475416d0e0d&quot;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><details><summary>查看响应示例:</summary><div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-json"><span class="line"><span style="color:#D4D4D4;">{</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;code&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;message&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;0&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;ttl&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;data&quot;</span><span style="color:#D4D4D4;">: {</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;is_valid&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;grisk_id&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;2e91cf2b67172ca8432fe7c9ab66a5c4&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">  }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details>`,27))])}const b=d(c,[["render",u]]),y=JSON.parse('{"path":"/docs/misc/sign/v_voucher.html","title":"v_voucher 验证","lang":"zh-CN","frontmatter":{},"git":{"updatedTime":1744996652000,"contributors":[{"name":"SessionHu","username":"SessionHu","email":"102411014+SessionHu@users.noreply.github.com","commits":3,"url":"https://github.com/SessionHu"},{"name":"SocialSisterYi","username":"SocialSisterYi","email":"45892418+SocialSisterYi@users.noreply.github.com","commits":1,"url":"https://github.com/SocialSisterYi"}],"changelog":[{"hash":"17b0e43ec2573a3b7f99d5c4c204a4f3b7f9641b","time":1744996652000,"email":"102411014+SessionHu@users.noreply.github.com","author":"SessionHu","message":"feat: add details"},{"hash":"1e24c6b1889160c4c35c01416aa4239501accf5f","time":1726759053000,"email":"102411014+SessionHu@users.noreply.github.com","author":"Session小胡","message":"调整部分接口描述与错误修复 (#1088)","coAuthors":[{"name":"社会易姐QwQ","email":"45892418+SocialSisterYi@users.noreply.github.com"}]},{"hash":"60a0c5d1a2f44fe61335da04571305fa7727a968","time":1724238159000,"email":"102411014+SessionHu@users.noreply.github.com","author":"Session小胡","message":"feat: 各种接口补充与错误修正 (#1066)"}]},"filePathRelative":"docs/misc/sign/v_voucher.md"}');export{b as comp,y as data};
