chromiumapp.org 扩展重定向如何为 Google Chrome 工作?

How do chromiumapp.org extension redirects work for Google Chrome?

当您创建 Chrome 扩展程序并希望使用 OAuth 2.0 时,您可以使用 https://<app-id>.chromiumapp.org/* URL 并因此能够让远程服务器直接访问您的浏览器实例(之前回答 - 例如 )。有谁知道或能够从理论上说明这是如何工作的?您是否能够在您的浏览器中定位任何请求,或者这是否仅适用于 OAuth 2.0?

这由 WebAuthFlow class 处理,其目的如下:

Given a provider URL, load the URL and perform usual web navigation until it results in redirection to a valid extension redirect URL. The provider can show any UI to the user if needed before redirecting to an appropriate URL.

当服务器指示浏览器重定向到有效的扩展重定向 URL 时,URL 将被传递给提供给 chrome.identity.launchWebAuthFlow.

的回调函数

'appropriate' URL 硬编码在 web_auth_flow.cc 中:

static const char kChromeExtensionSchemeUrlPattern[] =
    "chrome-extension://%s/";
static const char kChromiumDomainRedirectUrlPattern[] =
    "https://%s.chromiumapp.org/";

所以特殊的 URL https://<app-id>.chromiumapp.org/* 仅在 chrome.identity API 的 WebAuthFlow 上下文中有效。请注意,该机制完全是 Chrome 内部的。从未请求 URL。