如何运行MSAL样本?

问题描述

我正在努力了解运行msal样品的正确过程。

这是我尝试过的。...

  • 使用microsoft-authentication-library-for-js克隆主git clone https://github.com/AzureAD/microsoft-authentication-library-for-js.git存储库
  • 根据说明here,我尝试了以下操作...
// Change to the root of the msal repo
cd microsoft-authentication-library-for-js/
// Install npm dependencies and bootstrap packages
npm install
// Build library
npm run build

这将返回以下错误...

@azure/msal-browser: [!] (plugin rpt2) Error: E:/Important Documents/Programming/microsoft-authentication-library-for-js/lib/msal-browser/src/index.ts(34,8): semantic error TS2307: Cannot find module '@azure/msal-common'.
@azure/msal-browser: src\index.ts
@azure/msal-browser: Error: E:/Important Documents/Programming/microsoft-authentication-library-for-js/lib/msal-browser/src/index.ts(34,8): semantic error TS2307: Cannot find module '@azure/msal-common'.
  • 然后我尝试了其他说明...
// Change to the msal-browser package directory
cd lib/msal-browser/
// Ensure you are using the local build of msal-common
npm link @azure/msal-common
// To run build for common and browser package
npm run build:all

这将返回以下错误

src/index.ts → ./dist/index.js,./dist/index.es.js,./lib/msal-browser.js...
[!] (plugin rpt2) Error: E:/Important Documents/Programming/microsoft-authentication-library-for-js/lib/msal-browser/src/app/ClientApplication.ts(8,534): semantic error TS2305: Module '"../../../../../../../Important Documents/Programming/microsoft-authentication-library-for-js/lib/msal-browser/node_modules/@azure/msal-common/dist/src"' has no exported member 'ThrottlingUtils'.
src\app\ClientApplication.ts
Error: E:/Important Documents/Programming/microsoft-authentication-library-for-js/lib/msal-browser/src/app/ClientApplication.ts(8,534): semantic error TS2305: Module '"../../../../../../../Important Documents/Programming/microsoft-authentication-library-for-js/lib/msal-browser/node_modules/@azure/msal-common/dist/src"' has no exported member 'ThrottlingUtils'.
  • 然后我更新了./app/<sample-name>/authConfig.js文件夹中的VanillaJSTestApp2.0文件以匹配我在Azure门户中的设置
  • 然后我用VanillaJSTestApp2.0进入cd samples/msal-browser-samples/VanillaJSTestApp2.0文件
  • 我跑了npm install
  • 我跑了npm start并导航到http://localhost:30662/

虽然我可以看到带有引导程序控件的网站,但是当我单击任一Sign In控件时,什么也没有发生。

最初浏览该网站时记录以下错误

Uncaught ReferenceError: msal is not defined
    at auth.js:16

单击任一Sign In选项时会记录以下错误

auth.js:44 Uncaught (in promise) ReferenceError: Cannot access 'myMSALObj' before initialization
    at signIn (auth.js:44)
    at HTMLButtonElement.onclick ((index):22)

我在做什么错了?

我在Windows上使用VSCode。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)