当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。