Azure active directory Azure AD:MSAL-Cypress登录:ClientAuthError-base64字符串无效

Azure active directory Azure AD:MSAL-Cypress登录:ClientAuthError-base64字符串无效,azure-active-directory,base64,cypress,msal,azure-ad-graph-api,Azure Active Directory,Base64,Cypress,Msal,Azure Ad Graph Api,正在尝试从Cypress执行静默登录。在本地存储中设置msal.client.info时,收到一个错误“Invalid base64 string”,并且它不是web应用程序的登录用户。试图通过导入@azure/MSAL browser添加MSAL.clientInfo。但是,没有运气。你能告诉我这里出了什么问题吗 import * as MSAL from "@azure/msal-browser" Cypress.Commands.add("login&quo

正在尝试从Cypress执行静默登录。在本地存储中设置msal.client.info时,收到一个错误“Invalid base64 string”,并且它不是web应用程序的登录用户。试图通过导入@azure/MSAL browser添加MSAL.clientInfo。但是,没有运气。你能告诉我这里出了什么问题吗

import * as MSAL from "@azure/msal-browser"

Cypress.Commands.add("login", () => {
    cy.request({
      method: "POST",
      url: `https://login.microsoftonline.com/${Cypress.config("tenantId")}/oauth2/token`,
      form: true,
      body: {
        grant_type: "client_credentials",
        client_id: Cypress.config("clientId"),
        client_secret: Cypress.config("clientSecret"),
        resource: Cypress.config("resource")
      },
    }).then(response => {
      const MSALToken = response.body.access_token;
      const expiresOn = response.body.expires_on;
      console.log("Body: " + JSON.stringify(response.body));
      window.localStorage.setItem("msal.token.keys", `${Cypress.config("clientId")}|`);
      window.localStorage.setItem(`msal.access.token.key${Cypress.config("clientId")}`, MSALToken);
      window.localStorage.setItem(`msal.expiration.key${Cypress.config("clientId")}`, expiresOn);
      window.localStorage.setItem("msal.idtoken", MSALToken);
      window.localStorage.setItem(`msal.client.info`, MSAL.clientInfo);
    });
  });
收到的答复:

{
  "token_type": "Bearer",
  "expires_in": "3599",
  "ext_expires_in": "3599",
  "expires_on": "1622095375",
  "not_before": "1622091475",
  "resource": "00000002-0000-0000-c000-000000000000",
  "access_token": "eyJ0eXAiOiJKV1QiLCJh....BEFg"
}
设置时获取错误“无效的base64字符串”

window.localStorage.setItem(`msal.client.info`, MSAL.clientInfo);


Unhandled Promise rejection: The client info could not be parsed/decoded correctly. Please review the trace to determine the root cause. Failed with error: Error: Invalid base64 string ; Zone: <root> ; Task: Promise.then ; Value: ClientAuthError: The client info could not be parsed/decoded correctly. Please review the trace to determine the root cause. Failed with error: Error: Invalid base64 string
    at e [as constructor] (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1)
    at new e (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1)
    at Function.e.createClientInfoDecodingError (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1)
    at new t (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1)
    at t.getAccount (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1)
    at t.checkAccount (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1)
    at new t (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1)
    at Object.FG+x.t.ɵfac [as factory] (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1)
    at Nr.hydrate (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1)
    at Nr.get (VM19 main-es2015.5d1f7b11d6a7d9a05ff5.js:1) ClientAuthError: The client info could not be parsed/decoded correctly. Please review the trace to determine the root cause. Failed with error: Error: Invalid base64 string
window.localStorage.setItem(`msal.client.info`,msal.clientInfo);
未处理的承诺拒绝:无法正确解析/解码客户端信息。请查看跟踪以确定根本原因。失败,错误:错误:base64字符串无效;区域:;任务:承诺;值:ClientAuthError:无法正确解析/解码客户端信息。请查看跟踪以确定根本原因。失败,错误:错误:base64字符串无效
在e[作为建造商](VM19主-es2015.5D1F7B1D6A7D9A05FF5.js:1)
在新e(VM19 main-es2015.5D1F7B1D6A7D9A05FF5.js:1)
at Function.e.createClientInfoDecodingError(VM19 main-es2015.5D1F7B1D6A7D9A05FF5.js:1)
在新t(VM19 main-es2015.5D1F7B1D6A7D9A05FF5.js:1)
在t.getAccount(VM19 main-es2015.5D1F7B1D6A7D9A05FF5.js:1)
t.支票账户(VM19 main-es2015.5D1F7B1D6A7D9A05FF5.js:1)
在新t(VM19 main-es2015.5D1F7B1D6A7D9A05FF5.js:1)
at Object.FG+x.t.ɵfac[作为工厂](VM19 main-es2015.5D1F7B1D6A7D9A05FF5.js:1)
天然气水合物(VM19 main-es2015.5D1F7B1D6A7D9A05FF5.js:1)
在Nr.get(VM19 main-es2015.5D1F7B1D6A7D9A05FF5.js:1)客户端权限错误:无法正确解析/解码客户端信息。请查看跟踪以确定根本原因。失败,错误:错误:base64字符串无效