当 OAuth2 客户端请求获取新的访问令牌时,Web 浏览器会显示一个网页,要求用户授权并使用用户名和密码登录。
该 HTML 页面默认包含在服务器组件中,但可以通过 OnAuth2BeforeDispatchPage 事件进行自定义。
procedure OnOAuth2BeforeDispatchPage(Sender: TObject; OAuth2: TsgcHTTPOAuth2Request; var HTML: string); begin HTML := 'your custom html'; end;
如果您使用全新的 HTML 代码进行自定义,至少需要保留用于提交用户名和密码的表单:
<form action=""> <input type="hidden" name="request_type" value="sign-in" /> <input type="username" name="username" placeholder="Username" /> <input type="password" name="password" placeholder="Password" /> <input type="hidden" name="id" value="" /> <button>Sign In</button> </form>
其中隐藏字段 id 必须保留原始表单中的值,以便服务器能够识别该请求。
