當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


JavaScript ArcGIS OAuthInfo.flowType用法及代碼示例

基本信息

以下是所在類或對象的基本信息。

AMD: require(["esri/identity/OAuthInfo"], (OAuthInfo) => { /* code goes here */ });

ESM: import OAuthInfo from "@arcgis/core/identity/OAuthInfo";

類: esri/identity/OAuthInfo

繼承: OAuthInfo > Accessor

自從:用於 JavaScript 4.0 的 ArcGIS API

用法說明

OAuthInfo.flowType函數(或屬性)的定義如下:

flowType String


自從:ArcGIS 適用於 JavaScript 4.23 的 API

設置此屬性以指定要使用的身份驗證類型。一步驗證已被推薦的兩步方法取代(即 grant_type=authorization-code )。

此更新與OAuth 2.1 建議中的建議一致。

可能的值 說明
auto 自動默認為兩步驗證PKCE如果從 ArcGIS Online 或 ArcGIS Enterprise 版本 10.9 或更高版本訪問資源,並且popupfalse.如果訪問 ArcGIS Enterprise 的早期版本,或者如果popuptrue.如果需要彈出窗口,請使用下麵說明的authorization-code 流程。
authorization-code 相似auto,這也使用兩步驗證PKCE.將此類型用於使用彈出窗口.這不會檢查服務器版本。如果在沒有 PKCE 支持的舊服務器版本上訪問資源,請不要使用此類型。
implicit 一步認證。這不再是推薦的方法,並且已被兩步身份驗證所取代。如果使用較舊的服務器版本(即 10.9 之前),請使用此類型。請參閱OAuth 2.0 Security Best Current Practices 了解更多信息。

通過彈出窗口登錄應用程序時,引用的回調頁麵應該與使用的任何身份驗證類型兼容。默認的 oauth-callback.html 已更新,以允許在兩步方法中進行這些更新,但如果使用一步流程,它仍然有效。

可能的值"auto"|"authorization-code"|"implicit"

默認值:auto

例子:

// Default workflow
let infoAuto = new OAuthInfo({
  appId: "<put client id here>",
  flowType: "auto" // Default. If using a supported server/portal version and no popup, two-step authentication is used. If not, reverts to `implicit`.
  popup: false // Default
});
// Two-step workflow
let infoCode = new OAuthInfo({
  appId: "<put client id here>",
  flowType: "authorization-code" //  If using supported server/portal version and a popup, two-step authentication is used.
  popup: true,
  popupCallbackUrl: "oauth-callback.html" // Make sure the callback page supports this approach
});
// One-step workflow
let infoImplicit = new OAuthInfo({
  appId: "<put client id here>",
  flowType: "implicit" // no longer recommended. Should be used if working with older versions of Server/Portal, (ie. <10.9).
  popup: true,
  popupCallbackUrl: "oauth-callback.html" // Updated callback page works with both two-step and one-step authentication
});

相關用法


注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 OAuthInfo.flowType。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。