api-tokens
路由 呢啲片段本身就係一整個回應,唔係回應入面嘅一塊。
API 權杖頁面:一次性顯示、建立表格、清單同撤銷掣。
每個例子都真係用得,不過入面啲連結唔會帶你去邊度。 HTML 顯示可以複製嘅標記。
四個權杖,其中兩個有效
撤銷表格會提交去頁面自己路徑下面嘅 /tokens/revoke、/tokens/revoke-agent 同 /tokens/revoke-all。將佢哋指去你個應用程式處理佢哋嘅地方。
<div rst-tokens >
<section rst-box >
<form rst-form method ="post" action ="/tokens" >
<div rst-field >
<label rst-field-label for ="agent" >代理名稱</label >
<input rst-input type ="text" id ="agent" name ="agent" maxlength ="40" >
</div >
<label rst-switch >
<input type ="checkbox" name ="for_self" value ="on" >
<span rst-switch-track aria-hidden ="true" ></span >
呢個權杖係畀我自己用,唔係畀代理
</label >
<fieldset rst-choice >
<legend >存取權</legend >
<div rst-choice-cards >
<label >
<input type ="radio" name ="access" value ="write" checked >
<span >
<span rst-choice-title >讀寫</span >
</span >
</label >
<label >
<input type ="radio" name ="access" value ="read" >
<span >
<span rst-choice-title >只讀</span >
</span >
</label >
</div >
</fieldset >
<div rst-field >
<label rst-field-label for ="expiry" >有效期至</label >
<select rst-input ="short" id ="expiry" name ="expiry" >
<option value ="30" >30 日</option >
<option value ="90" selected >90 日</option >
<option value ="365" >1 年</option >
<option value ="never" >永不</option >
</select >
</div >
<div rst-form-foot >
<button rst-btn ="primary lg" type ="submit" >建立權杖</button >
</div >
</form >
</section >
<div rst-card rst-tokens-list role ="table" aria-label ="權杖" >
<div rst-lrow ="head" role ="row" >
<span role ="columnheader" >權杖</span >
<span class ="rst-m-hide" role ="columnheader" >存取權</span >
<span class ="rst-m-hide" role ="columnheader" >建立時間</span >
<span class ="rst-m-hide" role ="columnheader" >上次使用</span >
<span class ="rst-m-hide" role ="columnheader" >有效期至</span >
<span role ="columnheader" ><span class ="rst-sr-only" >狀態</span ></span >
<span role ="columnheader" ><span class ="rst-sr-only" >操作</span ></span >
</div >
<div rst-lrow role ="row" >
<span class ="rst-nm" role ="rowheader" ><span rst-actor >Claude(代表 Grace Hopper)</span >
<small >
<code >k3Jx9QpL2mWa</code >
</small >
</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >存取權</span >讀寫</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >建立時間</span ><time datetime ="2026-08-02" >2026-08-02</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >上次使用</span ><time datetime ="2026-08-11" >2026-08-11</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >有效期至</span ><time datetime ="2026-10-31" >2026-10-31</time ></span >
<span rst-tokens-state role ="cell" ></span >
<span role ="cell" >
<details rst-row-menu name ="rst-menus" >
<summary aria-label ="Claude(代表 Grace Hopper) 嘅操作" >
<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><circle cx ="12" cy ="12" r ="1" /><circle cx ="12" cy ="5" r ="1" /><circle cx ="12" cy ="19" r ="1" /></svg >
</summary >
<div rst-row-menu-panel >
<form method ="post" action ="/tokens/revoke" >
<input type ="hidden" name ="id" value ="k3Jx9QpL2mWa" >
<button type ="submit" >撤銷</button >
</form >
</div >
</details >
</span >
</div >
<div rst-lrow role ="row" >
<span class ="rst-nm" role ="rowheader" ><span rst-actor >Grace Hopper</span >
<small >
<code >Qm2vR8sT4xYb</code >
</small >
</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >存取權</span >只讀</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >建立時間</span ><time datetime ="2026-08-02" >2026-08-02</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >上次使用</span ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >有效期至</span >永不</span >
<span rst-tokens-state role ="cell" ></span >
<span role ="cell" >
<details rst-row-menu name ="rst-menus" >
<summary aria-label ="Grace Hopper 嘅操作" >
<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><circle cx ="12" cy ="12" r ="1" /><circle cx ="12" cy ="5" r ="1" /><circle cx ="12" cy ="19" r ="1" /></svg >
</summary >
<div rst-row-menu-panel >
<form method ="post" action ="/tokens/revoke" >
<input type ="hidden" name ="id" value ="Qm2vR8sT4xYb" >
<button type ="submit" >撤銷</button >
</form >
</div >
</details >
</span >
</div >
<div rst-lrow role ="row" >
<span class ="rst-nm" role ="rowheader" ><span rst-actor >Codex(代表 Grace Hopper)</span >
<small >
<code >Zp7wN1cH6kLd</code >
</small >
</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >存取權</span >讀寫</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >建立時間</span ><time datetime ="2026-08-02" >2026-08-02</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >上次使用</span ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >有效期至</span >永不</span >
<span rst-tokens-state role ="cell" ><span rst-status rst-tone ="neutral" >已撤銷</span ></span >
</div >
<div rst-lrow role ="row" >
<span class ="rst-nm" role ="rowheader" ><span rst-actor >夜間匯入(代表 Grace Hopper)</span >
<small >
<code >Vb4tG9yK3nMe</code >
</small >
</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >存取權</span >只讀</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >建立時間</span ><time datetime ="2026-08-02" >2026-08-02</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >上次使用</span ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >有效期至</span ><time datetime ="2026-08-11" >2026-08-11</time ></span >
<span rst-tokens-state role ="cell" ><span rst-status rst-tone ="warning" >已過期</span ></span >
</div >
</div >
<div rst-tokens-revoke >
<form method ="post" action ="/tokens/revoke-agent" >
<input type ="hidden" name ="agent" value ="Claude" >
<button rst-btn type ="submit" >撤銷呢個代理嘅全部權杖:Claude</button >
</form >
<form method ="post" action ="/tokens/revoke-all" >
<button rst-btn ="danger" type ="submit" >撤銷全部權杖</button >
</form >
</div >
</div >
喺應用程式入面,呢個會去到 /tokens, /tokens/revoke, /tokens/revoke-agent, /tokens/revoke-all。喺呢度,佢嘅連結同表格都唔會去任何地方。
啱啱建立:秘密只顯示一次
喺建立表格嘅回應本身度顯示呢個,唔好重新導向:秘密只係喺嗰個回應入面,其他地方冇。
<div rst-tokens >
<div rst-callout rst-tone ="positive" tabindex ="-1" autofocus >
<span rst-callout-ic aria-hidden ="true" >
<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><circle cx ="12" cy ="12" r ="10" /><path d ="m9 12 2 2 4-4" /></svg >
</span >
<div rst-callout-body >
<strong >而家就複製呢個權杖。之後唔會再顯示。</strong >
<p >
<code rst-tokens-secret >harbour_k3Jx9QpL2mWa_6bD2qK9xWz4rT8vN1mP3sL7yF5hJ0cG2aE4uB</code >
</p >
</div >
</div >
<section rst-box >
<form rst-form method ="post" action ="/tokens" >
<div rst-field >
<label rst-field-label for ="agent" >代理名稱</label >
<input rst-input type ="text" id ="agent" name ="agent" maxlength ="40" >
</div >
<label rst-switch >
<input type ="checkbox" name ="for_self" value ="on" >
<span rst-switch-track aria-hidden ="true" ></span >
呢個權杖係畀我自己用,唔係畀代理
</label >
<fieldset rst-choice >
<legend >存取權</legend >
<div rst-choice-cards >
<label >
<input type ="radio" name ="access" value ="write" checked >
<span >
<span rst-choice-title >讀寫</span >
</span >
</label >
<label >
<input type ="radio" name ="access" value ="read" >
<span >
<span rst-choice-title >只讀</span >
</span >
</label >
</div >
</fieldset >
<div rst-field >
<label rst-field-label for ="expiry" >有效期至</label >
<select rst-input ="short" id ="expiry" name ="expiry" >
<option value ="30" >30 日</option >
<option value ="90" selected >90 日</option >
<option value ="365" >1 年</option >
<option value ="never" >永不</option >
</select >
</div >
<div rst-form-foot >
<button rst-btn ="primary lg" type ="submit" >建立權杖</button >
</div >
</form >
</section >
<div rst-card rst-tokens-list role ="table" aria-label ="權杖" >
<div rst-lrow ="head" role ="row" >
<span role ="columnheader" >權杖</span >
<span class ="rst-m-hide" role ="columnheader" >存取權</span >
<span class ="rst-m-hide" role ="columnheader" >建立時間</span >
<span class ="rst-m-hide" role ="columnheader" >上次使用</span >
<span class ="rst-m-hide" role ="columnheader" >有效期至</span >
<span role ="columnheader" ><span class ="rst-sr-only" >狀態</span ></span >
<span role ="columnheader" ><span class ="rst-sr-only" >操作</span ></span >
</div >
<div rst-lrow role ="row" >
<span class ="rst-nm" role ="rowheader" ><span rst-actor >Claude(代表 Grace Hopper)</span >
<small >
<code >k3Jx9QpL2mWa</code >
</small >
</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >存取權</span >讀寫</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >建立時間</span ><time datetime ="2026-08-02" >2026-08-02</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >上次使用</span ><time datetime ="2026-08-11" >2026-08-11</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >有效期至</span ><time datetime ="2026-10-31" >2026-10-31</time ></span >
<span rst-tokens-state role ="cell" ></span >
<span role ="cell" >
<details rst-row-menu name ="rst-menus" >
<summary aria-label ="Claude(代表 Grace Hopper) 嘅操作" >
<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><circle cx ="12" cy ="12" r ="1" /><circle cx ="12" cy ="5" r ="1" /><circle cx ="12" cy ="19" r ="1" /></svg >
</summary >
<div rst-row-menu-panel >
<form method ="post" action ="/tokens/revoke" >
<input type ="hidden" name ="id" value ="k3Jx9QpL2mWa" >
<button type ="submit" >撤銷</button >
</form >
</div >
</details >
</span >
</div >
<div rst-lrow role ="row" >
<span class ="rst-nm" role ="rowheader" ><span rst-actor >Grace Hopper</span >
<small >
<code >Qm2vR8sT4xYb</code >
</small >
</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >存取權</span >只讀</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >建立時間</span ><time datetime ="2026-08-02" >2026-08-02</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >上次使用</span ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >有效期至</span >永不</span >
<span rst-tokens-state role ="cell" ></span >
<span role ="cell" >
<details rst-row-menu name ="rst-menus" >
<summary aria-label ="Grace Hopper 嘅操作" >
<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><circle cx ="12" cy ="12" r ="1" /><circle cx ="12" cy ="5" r ="1" /><circle cx ="12" cy ="19" r ="1" /></svg >
</summary >
<div rst-row-menu-panel >
<form method ="post" action ="/tokens/revoke" >
<input type ="hidden" name ="id" value ="Qm2vR8sT4xYb" >
<button type ="submit" >撤銷</button >
</form >
</div >
</details >
</span >
</div >
<div rst-lrow role ="row" >
<span class ="rst-nm" role ="rowheader" ><span rst-actor >Codex(代表 Grace Hopper)</span >
<small >
<code >Zp7wN1cH6kLd</code >
</small >
</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >存取權</span >讀寫</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >建立時間</span ><time datetime ="2026-08-02" >2026-08-02</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >上次使用</span ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >有效期至</span >永不</span >
<span rst-tokens-state role ="cell" ><span rst-status rst-tone ="neutral" >已撤銷</span ></span >
</div >
<div rst-lrow role ="row" >
<span class ="rst-nm" role ="rowheader" ><span rst-actor >夜間匯入(代表 Grace Hopper)</span >
<small >
<code >Vb4tG9yK3nMe</code >
</small >
</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >存取權</span >只讀</span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >建立時間</span ><time datetime ="2026-08-02" >2026-08-02</time ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >上次使用</span ></span >
<span rst-tokens-fact role ="cell" ><span rst-tokens-fact-label >有效期至</span ><time datetime ="2026-08-11" >2026-08-11</time ></span >
<span rst-tokens-state role ="cell" ><span rst-status rst-tone ="warning" >已過期</span ></span >
</div >
</div >
<div rst-tokens-revoke >
<form method ="post" action ="/tokens/revoke-agent" >
<input type ="hidden" name ="agent" value ="Claude" >
<button rst-btn type ="submit" >撤銷呢個代理嘅全部權杖:Claude</button >
</form >
<form method ="post" action ="/tokens/revoke-all" >
<button rst-btn ="danger" type ="submit" >撤銷全部權杖</button >
</form >
</div >
</div >
喺應用程式入面,呢個會去到 /tokens, /tokens/revoke, /tokens/revoke-agent, /tokens/revoke-all。喺呢度,佢嘅連結同表格都唔會去任何地方。
仲未有權杖
<div rst-tokens >
<section rst-box >
<form rst-form method ="post" action ="/tokens" >
<div rst-field >
<label rst-field-label for ="agent" >代理名稱</label >
<input rst-input type ="text" id ="agent" name ="agent" maxlength ="40" >
</div >
<label rst-switch >
<input type ="checkbox" name ="for_self" value ="on" >
<span rst-switch-track aria-hidden ="true" ></span >
呢個權杖係畀我自己用,唔係畀代理
</label >
<fieldset rst-choice >
<legend >存取權</legend >
<div rst-choice-cards >
<label >
<input type ="radio" name ="access" value ="write" checked >
<span >
<span rst-choice-title >讀寫</span >
</span >
</label >
<label >
<input type ="radio" name ="access" value ="read" >
<span >
<span rst-choice-title >只讀</span >
</span >
</label >
</div >
</fieldset >
<div rst-field >
<label rst-field-label for ="expiry" >有效期至</label >
<select rst-input ="short" id ="expiry" name ="expiry" >
<option value ="30" >30 日</option >
<option value ="90" selected >90 日</option >
<option value ="365" >1 年</option >
<option value ="never" >永不</option >
</select >
</div >
<div rst-form-foot >
<button rst-btn ="primary lg" type ="submit" >建立權杖</button >
</div >
</form >
</section >
<div rst-empty >
<p rst-empty-body >仲未有權杖。</p >
</div >
</div >
喺應用程式入面,呢個會去到 /tokens。喺呢度,佢嘅連結同表格都唔會去任何地方。