sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

AadHttpClient - not getting token in Edge browser anymore

Open AndreasNorefalk opened this issue 7 years ago • 16 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

Expect token to be returned with TokenFactoryiframe when using AadHttpClient in spfx also in the Edge browser. Has worked before but recently stopped working.

Observed Behavior

Works for other browsers like Chrome, Firefox and IE, but not Edge (not even in In Private mode).

Steps to Reproduce

Test a web part using AadHttpClient in Edge and in Chrome, to see the difference.

AndreasNorefalk avatar Jun 07 '19 08:06 AndreasNorefalk

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Jun 07 '19 08:06 msft-github-bot

hey @AndreasNorefalk, we are not aware of any regressions here especially on Edge. Can you please share the example or tell us the steps to repro the issue?

thanks a lot

lucabandMSFT avatar Jun 07 '19 15:06 lucabandMSFT

Have tried both using the AadHttpClient with: new AadHttpClient(..) and through the factory with this.context.aadHttpClientFactory. They both have stopped working in Edge.

Getting the token through aadTokenProviderFactory and then using the regular HttpClient however seems to be working fine in Edge.

AndreasNorefalk avatar Jun 10 '19 07:06 AndreasNorefalk

Thanks @AndreasNorefalk. Can you please share the sample code that doesn't work for you? also, what version of Edge is not working for you?

thanks

lucabandMSFT avatar Jun 10 '19 15:06 lucabandMSFT

hi, I am not sure if this is related so I post this issue over here as we are having issue with edge too. I can see we are able to retrieve the token ( i tested the token by grabbing it and use it in Postman and the token is valid and the call was successful)

What i have found so far: I identified the issue in this file https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-05-31.011/sp-pages-assembly_en-au_226a2c779e07f656911b8c4964fa1b69.js

return n.headers = new Headers(n.headers || void 0), n.headers.append("Authorization", "Bearer " + o), g.fetchCore(r, new Request(t, n), s._serviceScope, s._fetchProvider, e._className);

i have highlighted the issue in Edge as it would throw invalid argument error

We are using spfx 1.8.1 and Edge version is 44.18362.1.0

regards

christianteh avatar Jun 11 '19 00:06 christianteh

Hi, the following Edge version:

Microsoft Edge 44.17763.1.0 Microsoft EdgeHTML 18.17763

Example: let apiClient = new AadHttpClient(this.props.context.serviceScope, adalConfig.clientId); apiClient.get(url, AadHttpClient.configurations.v1, { cache: "no-cache" }).then(response => { resolve(response); }).catch(err => { reject(err); });

AndreasNorefalk avatar Jun 11 '19 07:06 AndreasNorefalk

I am having the same issue. Both in a normal and isolated SPFX webparts. My Edge is a bit older: Microsoft Edge 41.16299.1004.0.

Receiving this error: TypeError: Invalid argument at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client-prod_2019-05-31.012/isolated-web-part-application-assembly_default_fd8d4d8aab6464fb64e6cd4cd176ee17.js:516:42819)

SuleymanA avatar Jun 11 '19 12:06 SuleymanA

Same issue here. Calling the AadHttpClientFactory:

this.aadClient = await this.context.aadHttpClientFactory.getClient(AppSettings.AppId); let httpResponse: HttpClientResponse = await this.aadClient .get(${AppSettings.WebApiUrl}/${groupId}, AadHttpClient.configurations.v1);

Receiving this error: TypeError: Invalid argument

Using Edge: Microsoft Edge 44.17763.1.0 and SPFx 1.8.1

rfjschouten avatar Jun 11 '19 12:06 rfjschouten

We are now actively looking into this. Thanks for reporting the issue.

VesaJuvonen avatar Jun 11 '19 16:06 VesaJuvonen

Thank you Vesa! My client would really appreciatie this...

rfjschouten avatar Jun 11 '19 18:06 rfjschouten

I have the same issue

Internet Explorer Edge: 18.17763 SPFx: 1.8.2

with: AadHttpClientFactory

Call azure web api as anonymous and the error is: Invalid argument

SPFxDeveloper avatar Jun 11 '19 20:06 SPFxDeveloper

hey guys we have to make sure the header isn't undefined. so this is what you can do

    const requestHeaders: Headers = new Headers();
    requestHeaders.append('Accept', 'application/json');
    const httpClientOptions: IHttpClientOptions = {
      headers: requestHeaders
    };
    return client
      .get(url, AadHttpClient.configurations.v1,httpClientOptions)

obviously you can add whatever header you like/appropriate/applicable to you

this has been tested and working for IE edge

spfx 1.8.1 and Edge version is 44.18362.1.0

regards

christianteh avatar Jun 11 '19 23:06 christianteh

You won me the answer.

It works for me:

const requestHeaders: Headers = new Headers(); requestHeaders.append('Content-type', 'application/json'); requestHeaders.append('Cache-Control', 'no-cache');

return client.get('https://...', AadHttpClient.configurations.v1, { cache: "no-cache", headers: requestHeaders })

In IE it worked fine, but now I have to execute the call twice for the changes to be refiled, that's why I got the handling of the cache, if someone knows how to correct it, tell how to do it please

SPFxDeveloper avatar Jun 11 '19 23:06 SPFxDeveloper

There was a regression in the service that caused this issue. This issue should now be resolved. Please open a new issue if you're still seeing this behavior.

Thanks!

ghost avatar Jun 12 '19 17:06 ghost

I can confirm this is working now! Thanks @lahuey and @VesaJuvonen for the quick action on this.

rfjschouten avatar Jun 13 '19 09:06 rfjschouten

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 24 '20 06:01 msft-github-bot