Guide
使用@Capacitor/__CAPGO_KEEP_1__-intune
使用@capgo/capacitor-intune
Capacitor plugin for Microsoft Intune MAM enrollment, app protection policies, app config, and MSAL authentication.
Install
bun add @capgo/capacitor-intune
bunx cap sync
bunx cap sync 查看code
导入
import { IntuneMAM } from '@capgo/capacitor-intune';
API概览
| 方法 | 描述 |
|---|---|
acquireToken |
呈现 Microsoft 登录流程并返回访问令牌及帐户元数据。 |
acquireTokenSilent |
从 MSAL 缓存中获取之前登录用户的令牌。 |
registerAndEnrollAccount |
将之前已验证的帐户注册到 Intune 并开始注册。 |
loginAndEnrollAccount |
要求 Intune 在未先请求应用令牌的情况下对用户进行身份验证和注册。 |
enrolledAccount |
上下文:Capgo 营销网站。角色:呼吁动作按钮或链接标签。见于组件 AskAiSection.astro。消息键 `ask_ai_button` (Ask Ai Button)。 |
deRegisterAndUnenrollAccount |
返回当前已注册的 Intune 帐户,如果有的话。 |
logoutOfAccount |
从 Intune 中注销帐户并触发选择性擦除时适用。 |
appConfig |
从 MSAL 中注销用户而不注销 Intune 帐户时签出用户。 |
getPolicy |
获取当前有效的 Intune 应用保护策略。 |
groupName |
便捷工具,用于解析 Intune 应用配置值。 GroupName 获取应用配置值时使用此工具。 |
sdkVersion |
返回本地 Intune 和 MSAL SDK 版本,通过此插件打包。 |
displayDiagnosticConsole |
显示 native Intune 诊断 UI。 |
示例
acquireToken()
在 Microsoft 登录流程中呈现并返回访问令牌及帐户元数据。
import { IntuneMAM } from '@capgo/capacitor-intune';
const result = await IntuneMAM.acquireToken({ scopes: ['openid'] });
// The result holds sensitive values: use it without logging it.
acquireTokenSilent()
呈现 Microsoft 登录流程并返回访问令牌及帐户元数据。
import { IntuneMAM } from '@capgo/capacitor-intune';
const result = await IntuneMAM.acquireTokenSilent({
scopes: ['openid'],
accountId: 'acquireToken',
});
// The result holds sensitive values: use it without logging it.
registerAndEnrollAccount()
从 MSAL 缓存中获取之前登录用户的令牌。
import { IntuneMAM } from '@capgo/capacitor-intune';
await IntuneMAM.registerAndEnrollAccount({ accountId: 'account-id-123' });
loginAndEnrollAccount()
将已验证的帐户注册到 Intune 并开始注册流程。
import { IntuneMAM } from '@capgo/capacitor-intune';
await IntuneMAM.loginAndEnrollAccount();
enrolledAccount()
在 Intune 中验证并注册用户,且不需要先获取应用令牌。
import { IntuneMAM } from '@capgo/capacitor-intune';
const result = await IntuneMAM.enrolledAccount();
console.log(result);
deRegisterAndUnenrollAccount()
从 Intune 中注销账户并在适用时触发选择性擦除。
import { IntuneMAM } from '@capgo/capacitor-intune';
await IntuneMAM.deRegisterAndUnenrollAccount({ accountId: 'account-id-123' });
上表列出了 12 个核心方法。监听器和版本助手,以及每个方法的完整契约,均在以下仓库中进行了文档记录。 GitHub 仓库.
监听事件
addListener 返回一个句柄。调用 handle.remove() 当屏幕卸载时,或者 IntuneMAM.removeAllListeners() 以清除所有监听器。
完整参考
继续使用 @capgo/capacitor-intune
如果您正在使用 使用@capgo/capacitor-intune 规划身份验证和帐户流程,连接它与 @capgo/capacitor-intune 查看@capgo/capacitor-intune中的实现细节 开始使用 查看开始使用中的实现细节 @capgo/capacitor-社交登录 查看@capgo/capacitor-social-login中的实现细节 @capgo/capacitor-passkey 查看@capgo/capacitor-passkey中的实现细节,并 @capgo/capacitor-native-biometric 查看@capgo/capacitor-native-biometric中的实现细节