@aminebizid/nativescript-adal
Microsoft 活动目录身份验证库的 NativeScript 插件。
npm i --save @aminebizid/nativescript-adal

NativeScript 活动目录身份验证库插件

此插件允许您快速将 Azure 活动目录身份验证添加到您的 NativeScript 应用程序。感谢 NavaraBV。

先决条件/需求

您的应用程序需要在 Azure 活动目录 (AAD) 中注册。访问 Azure 门户 并使用您的组织账户登录。在注册应用程序后,获取您的 Azure AD 租户 ID 和应用程序 ID。

安装

tns plugin add @aminebizid/nativescript-adal

使用方法(Angular 示例)

在应用程序中导入 AdalContext 类,例如在 'AdalService' 中,并初始化它。

import { Injectable } from '@angular/core';
import { AdalContext } from '@aminebizid/nativescript-adal';

const authority: string = 'https://login.microsoftonline.com/{your-tenant-id}';
const clientId: string = '{your-application-id}';
const resourceId: string = '00000002-0000-0000-c000-000000000000';

@Injectable()
export class AdalService {

public adalContext: AdalContext;

constructor() {
this.adalContext = new AdalContext(authority, clientId, resourceId);
}
}

...然后在您的应用程序中使用此服务!

export class AppComponent {

constructor(private adalService: AdalService) { }

public login() {
this.adalService.adalContext.login().then((result) => {
console.log('Success!');
})
}

public logout() {
this.adalService.adalContext.logout();
}
}

许可证

有关详细信息,请参阅 LICENSE