OAuthCallback

TsgcHTMLComponent_OAuthCallback — 渲染一个处于成功、错误或加载状态的 OAuth 落地页,显示已登录用户和自动重定向,适用于 Delphi、C++ Builder 和 .NET。

TsgcHTMLComponent_OAuthCallback

从您的 OAuth 重定向 URI 提供的页面。设置 Status 和用户详情,然后读取 HTML — 或使用静态的 BuildSuccessBuildErrorBuildLoading 辅助方法实现一行代码。

组件类

TsgcHTMLComponent_OAuthCallback

渲染为

Bootstrap 5 回调页

家族

身份验证

语言

Delphi, C++ Builder, .NET

每种结果一行代码

静态 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 选择 csSuccesscsErrorcsLoading — 一个对勾、一个叉号或一个旋转器,并配有匹配的文案。

用户信息

ProviderNameUserNameUserEmailUserAvatar 填充成功卡片;ShowUserInfoAvatarSize 控制其显示。

重定向

RedirectURL 配合 RedirectMethodrmAutoRedirectrmButtonOnlyrmNone)和 RedirectDelay 驱动登录后的导航。

图标与布局

SuccessIconColorEnumErrorIconColorEnumSuccessIconTextErrorIconText(以及原始的 *IconHTML/*IconColor)加上 MaxWidth 为卡片设置样式。

输出

HTML 返回回调卡片;ErrorMessage 在错误状态下填充危险提示。从您的 OAuth 重定向 URI 提供它。

继续探索

所有 sgcHTML 组件浏览 60 多个组件的完整功能矩阵。
下载免费试用版30 天试用版附带 60.HTML 演示项目。
价格Single、Team 和 Site 授权,均含完整源代码。

准备好开始了吗?

下载免费试用版,为您的 Delphi、C++ Builder 或 .NET Web 应用添加 OAuth 回调页面。