0

我有一个带有 2 个自定义策略的 azure ad b2c,一个用于统一登录/向上页面,另一个用于密码重置。

当我创建一个帐户并登录时,我无法获得成功的响应https://graph.microsoft.com/v1.0/me,从中我得到以下错误:

AADB2C90077: User does not have an existing session and request prompt parameter has a value of 'None'. Correlation ID: 6ec76033-f72e-405d-ba1a-04c7534a571e Timestamp: 2018-08-21 00:56:07Z |interaction_required

我正在使用以下代码(使用 MSAL.js 和 axios)发出请求:

    const config = {
      tenant: 'tenant.onmicrosoft.com',
      clientId: 'app-id',
      signInSignUpPolicy: 'https://login.microsoftonline.com/tfp/my_tenant/policy/',
      passwordResetPolicy: 'https://login.microsoftonline.com/tfp/my_tenanat/my_pr_policy/',
      scopes: ['https://graph.microsoft.com/user.read'],
      redirectUri: 'http://theredirect.uri',
      cacheLocation: 'localStorage',
      graphUrl: 'https://graph.microsoft.com/v1.0',
    };

    /**
       * @returns {Promise<any>}
       */
      accessToken() {
        return new Promise(async (resolve, reject) => {
          try {
            const accessToken = await this.userAgent.acquireTokenSilent(config.scopes);
            resolve(accessToken);
          } catch (exception) {
            reject(exception);
            // this.userAgent.acquireTokenRedirect(config.scopes).then(resolve, reject);
          }
        });
      }

     /**
       * @param endpoint
       * @returns {AxiosPromise<any>}
       */
      async get(endpoint) {
        const accessToken = await this.accessToken();


        const requestConfig = {
          headers: { Authorization: 'Bearer ' + accessToken },
        };

        const url = config.graphUrl + "/" + endpoint;
        return axios.get(url, requestConfig);
      } 
4

1 回答 1

2

图形 API 仅可供 Azure AD“普通”用户和应用程序访问。含义 - 没有一个 B2C 用户,也被称为local将使用 GraphAPI。

如果您需要在 B2C 上使用图形 API,您唯一的机会是将应用程序标识用于在 B2C 租户的“正常”Azure AD 部分注册的应用程序 -更多信息和详细描述请点击此处

另请注意,Microsoft Graph 不适用于 B2C 用户。

于 2018-08-21T10:45:09.353 回答