Skip to content

The issue with calling Azure AD secured API by using AadHttpClient. #4840

@rememberDL

Description

@rememberDL

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

We use aadHttpClientFactory from SP context in order to work with Azure App Service API . And it worked very well.

Observed Behavior

When I call Azure App Service API by using AadHttpClient I get the error in the browser console:

TypeError: Cannot read property 'call' of undefined
    at o (listview-host-assembly_default_65e11fefa9767af7e7b350ea75aebfbd.js:19)
    at o.t (listview-host-assembly_default_65e11fefa9767af7e7b350ea75aebfbd.js:19)

Steps to Reproduce

  1. Create a SPFx 1.9.1 (it doesn't work both in version 1.9.1 and in version 1.7.1) extension (both ListView Command Set and Field Customizer) solution
  2. Use AadHttpClient to access Azure App Service

Sample code we use:

      const aadClicent = await this.context.aadHttpClientFactory.getClient(""8dexxx-xxx-xxx-xxx"");
      requestHeaders.append('Content-type', 'application/json');
      const httpClientOptions: IHttpClientOptions = {
        headers: requestHeaders
      };
      const response = await aadClicent.get("https://xxxxxx.azurewebsites.net/api/xxxxx/checkid/", 
          AadHttpClient.configurations.v1, httpClientOptions);
      const json = await response.json();

      if (response.status == 200) {
        return json;
      }
      else {
        return null;
      }

It should be noted: this.context above is ExtensionContext
This code worked very well until 2019-10-29.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:authCategory: Authentication (Azure AD / etc)area:spfxCategory: SharePoint Framework (not extensions related)status:fixedIssue was fixed in current or prior release.status:to-be-reviewedIssue needs to be reviewed by Microsoft for additional follow up / review.type:bug-confirmedConfirmed bug, not working as designed / expected.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions