OAuth2 | 服务器认证

当 OAuth2 客户端请求新授权时,服务器会显示一个网页,用户必须在该页面上允许连接然后登录。此页面由 sgcWebSockets 库提供,并在客户端请求授权时自动分发。

 

 

如果用户允许访问,将显示登录表单,用户须输入用户名和密码。

此数据将在 OnOAuth2Authentication 事件中接收,因此您必须验证用户名/密码是否正确,若正确则将 Authenticated 参数设为 true。

 


procedure OnAuth2Authentication(Connection: TsgcWSConnection; OAuth2: TsgcHTTPOAuth2Request; aUser, 
  aPassword: string; var Authenticated: Boolean);
begin
  if ((aUser = 'user') and (aPassword = 'secret')) then
    Authenticated := True;
end;