The issue with calling Azure AD secured API by using AadHttpClient.
Category
- [ ] Question
- [ ] Typo
- [x] 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
- 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
- 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.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
We get the same error when using MSGraphClient. It stopped working the last 2 hours.
this error happens with the aadHttpClientFactory as well as trying to get a token from the AadTokenProvider. Working fine from a WebPart but not in a CommandSet Extension (hence the listview related error).
Same issue here happening in 2 tenants. Our code was working fine before and nothing has changed. Same issue reported here: https://github.com/SharePoint/sp-dev-fx-extensions/issues/265
Same issue. Our code was working fine yesterday (2019-10-29).
Same here. This bug is a showstopper to our Azure related services. It started already 2019-10-28.
It stopped working for us too, please fix this ASAP as it is causing major issues and most of the applications don't work. 🧯🔥
We are facing the same issue. Extension in view worked perfectly before.
I'm unable to repro... was the issue possibly temporary?
Network trace two demo web parts... one uses AADHttpClient & the other uses MSGraphClient...

We're still experiencing it and is consistent. We're getting it on list extensions using AADHttpClient.

Please provide the code you're using to call the client... the following code is working in multiple tenants I've tested, so I'm not able to repro this...
public getCurrentUser(): Promise<any> {
return new Promise<any>((resolve, reject) => {
this.context.aadHttpClientFactory
.getClient('https://graph.microsoft.com')
.then((client: AadHttpClient) => {
client.get('https://graph.microsoft.com/v1.0/me', AadHttpClient.configurations.v1)
.then((response: HttpClientResponse) => {
return response.json();
})
.then((jsonResponse: any) => {
resolve(jsonResponse);
})
.catch((error) => {
reject(error);
});
});
});
}
This is some test code. It's trying to call an Azure function secured by AAD. Framework is v1.9.0
public test(): Promise<any> {
const requestOptions: IHttpClientOptions = {
body: JSON.stringify({
SiteUrl: "http://blah.com",
Fullpath: "/something.doc"
})
};
return new Promise<any>((resolve, reject) => {
this.context.aadHttpClientFactory
.getClient("320xxx-xxx-xxx-xxx") //App Id
.then((client: AadHttpClient): void => {
client.post('https://xxxxxxx.azurewebsites.net/api/ValidateFilename', AadHttpClient.configurations.v1, requestOptions)
.then((res: HttpClientResponse): Promise<any> => {
if (res.status == 200) {
return res.json();
} else {
throw new Error("An error occured. Please try again");
}
})
.catch(err => {
reject(err);
});
});
});
}
I've also been able to repro using this /me graph call in a fresh Yeoman helloworld listview customiser (v1.9.1) so not sure if it's tenant specific? It's occuring in both our O365 developer tenant and production tenant.
Please provide the code you're using to call the client... the following code is working in multiple tenants I've tested, so I'm not able to repro this...
public getCurrentUser(): Promise<any> { return new Promise<any>((resolve, reject) => { this.context.aadHttpClientFactory .getClient('https://graph.microsoft.com') .then((client: AadHttpClient) => { client.get('https://graph.microsoft.com/v1.0/me', AadHttpClient.configurations.v1) .then((response: HttpClientResponse) => { return response.json(); }) .then((jsonResponse: any) => { resolve(jsonResponse); }) .catch((error) => { reject(error); }); }); }); }
What's the release configuration of the tenants, TR/SR?
Dev tenant is TR for all. Production is TR for certain users - have tried for a TR and SR user and the same occurs.
I've just switched our dev tenant over to SR for all to see what happens - I assume this takes a while to have take effect so will report back once it does. Is there an easy way to tell if a user is seeing SR?
Dev tenant has now switched to SR and can confirmed the same issue exists whether SR or TR.
Same issue using fieldcustomizer on one of 3 tested tenants
sample code:

console.log is never hit instead error: “listview-host-assembly_default_65e11fefa9767af7e7b350ea75aebfbd.js:19 Uncaught (in promise) 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)” “https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-10-18.025/listview-host-assembly_default_65e11fefa9767af7e7b350ea75aebfbd.js” ” https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-10-18.025/listview-host-assembly_default_65e11fefa9767af7e7b350ea75aebfbd.js”
I noticed that we have the issue using both AadHttpClient and MSGraphClient with the latest version of SPFx 1.9.1. There is no issue when using older version of SPFx 1.7.0 on the same tenant.
I noticed that we have the issue using both AadHttpClient and MSGraphClient with the latest version of SPFx 1.9.1. There is no issue when using older version of SPFx 1.7.0 on the same tenant.
Strange I have a fieldcustomizer using 1.9.1 not working and a normal SPFx webpart also 1.9.1 which works on same tenant. Maybe it's just coincident that 1.7.0 works?
The SPFx which works is '"isDomainIsolated": true,' if that helps.
Another gues is that it my be related only to extensions. With a new fresh SPFx 1.9.1 webpart I have no issues using the graph client. I noticed the issue when using extensions.