OAuthCallback
TsgcHTMLComponent_OAuthCallback — 渲染一个处于成功、错误或加载状态的 OAuth 落地页,显示已登录用户和自动重定向,适用于 Delphi、C++ Builder 和 .NET。
TsgcHTMLComponent_OAuthCallback — 渲染一个处于成功、错误或加载状态的 OAuth 落地页,显示已登录用户和自动重定向,适用于 Delphi、C++ Builder 和 .NET。
从您的 OAuth 重定向 URI 提供的页面。设置 Status 和用户详情,然后读取 HTML — 或使用静态的 BuildSuccess、BuildError 和 BuildLoading 辅助方法实现一行代码。
静态 Build* 辅助方法直接渲染一个完成的页面。当您需要设置头像、重定向方法或自定义图标时,请使用完整组件。
uses
sgcHTML_Enums, sgcHTML_Component_OAuthCallback;
// Success page (with auto-redirect to /dashboard):
WebModule.Response := TsgcHTMLComponent_OAuthCallback.BuildSuccess(
'Google', 'Jane Doe', '/dashboard', 'jane@acme.com');
// Error page:
WebModule.Response := TsgcHTMLComponent_OAuthCallback.BuildError(
'Google', 'access_denied');
// Loading / interstitial page:
WebModule.Response := TsgcHTMLComponent_OAuthCallback.BuildLoading('Google');
// Full control:
var
oCB: TsgcHTMLComponent_OAuthCallback;
begin
oCB := TsgcHTMLComponent_OAuthCallback.Create(nil);
try
oCB.Status := csSuccess;
oCB.ProviderName := 'Google';
oCB.UserName := 'Jane Doe';
oCB.UserAvatar := 'https://acme.com/u/jane.png';
oCB.RedirectURL := '/dashboard';
oCB.RedirectMethod := rmAutoRedirect;
oCB.RedirectDelay := 3;
WebModule.Response := oCB.HTML;
finally
oCB.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_OAuthCallback.hpp
// Success page (with auto-redirect to /dashboard):
String ok = TsgcHTMLComponent_OAuthCallback::BuildSuccess(
"Google", "Jane Doe", "/dashboard", "jane@acme.com");
// Error page:
String err = TsgcHTMLComponent_OAuthCallback::BuildError(
"Google", "access_denied");
// Loading / interstitial page:
String wait = TsgcHTMLComponent_OAuthCallback::BuildLoading("Google");
// Full control:
TsgcHTMLComponent_OAuthCallback *oCB = new TsgcHTMLComponent_OAuthCallback(NULL);
try
{
oCB->Status = csSuccess;
oCB->ProviderName = "Google";
oCB->UserName = "Jane Doe";
oCB->UserAvatar = "https://acme.com/u/jane.png";
oCB->RedirectURL = "/dashboard";
oCB->RedirectMethod = rmAutoRedirect;
oCB->RedirectDelay = 3;
String html = oCB->HTML;
}
__finally
{
delete oCB;
}
using esegece.sgcWebSockets;
// Success page (with auto-redirect to /dashboard):
string ok = TsgcHTMLComponent_OAuthCallback.BuildSuccess(
"Google", "Jane Doe", "/dashboard", "jane@acme.com");
// Error page:
string err = TsgcHTMLComponent_OAuthCallback.BuildError(
"Google", "access_denied");
// Loading / interstitial page:
string wait = TsgcHTMLComponent_OAuthCallback.BuildLoading("Google");
// Full control:
var cb = new TsgcHTMLComponent_OAuthCallback();
cb.Status = TsgcHTMLOAuthCallbackStatus.csSuccess;
cb.ProviderName = "Google";
cb.UserName = "Jane Doe";
cb.UserAvatar = "https://acme.com/u/jane.png";
cb.RedirectURL = "/dashboard";
cb.RedirectMethod = TsgcHTMLOAuthRedirectMethod.rmAutoRedirect;
cb.RedirectDelay = 3;
string html = cb.HTML;
您最常使用的成员。
BuildSuccess(aProviderName, aUserName, aRedirectURL, aUserEmail)、BuildError(aProviderName, aErrorMessage) 和 BuildLoading(aProviderName) 通过一次调用渲染一个完成的页面。
Status 选择 csSuccess、csError 或 csLoading — 一个对勾、一个叉号或一个旋转器,并配有匹配的文案。
ProviderName、UserName、UserEmail 和 UserAvatar 填充成功卡片;ShowUserInfo 和 AvatarSize 控制其显示。
RedirectURL 配合 RedirectMethod(rmAutoRedirect、rmButtonOnly、rmNone)和 RedirectDelay 驱动登录后的导航。
SuccessIconColorEnum、ErrorIconColorEnum、SuccessIconText、ErrorIconText(以及原始的 *IconHTML/*IconColor)加上 MaxWidth 为卡片设置样式。
HTML 返回回调卡片;ErrorMessage 在错误状态下填充危险提示。从您的 OAuth 重定向 URI 提供它。