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

react-aad-webapi issue in hosted workbench or after deploying

Open ashuetawah opened this issue 8 years ago • 5 comments

Category

  • [ ] Question
  • [X] Bug
  • [ ] Enhancement

Expected or Desired Behavior

SPFx web part calls an API secured via Azure AD and API return the data to web part. This works well in local workbench. When I tried in SharePoint hosted workbench, it does not work. Even after bundling it and placing as an App on SP, it still does not work.

Observed Behavior

I am seeing pop up appearing and error returned on web part as - Error: Token renewal operation failed due to timeout

Steps to Reproduce

Samples extended during this work -
https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-aad-webapi

  1. Create API as defined in https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/connect-to-api-secured-with-aad#create-a-new-aspnet-web-api-project and stop before https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/connect-to-api-secured-with-aad#secure-the-api-using-openid
  2. APIs were published on AzureSubscription1.
  3. In AzureSubscription2 (which is a Azure AD based subscription), use guidance from https://docs.microsoft.com/en-us/azure/app-service/app-service-mobile-how-to-configure-active-directory-authentication#a-nameadvanced-aalternative-method-manually-configure-azure-active-directory-with-advanced-settings, Complete 6 steps process defined in https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/connect-to-api-secured-with-aad#register-azure-ad-application.
  4. In AzureSubscription2, register one more app with details a. as the name use Orders b. as the sign-in URL use https://your-machine:4321/temp/workbench.html where your-machine is the name of your developer machine c. add permissions to other applications i. change the filter to show all applications ii. from the list of applications select Orders API iii. the list of Delegated Permissions select "App created in step 3". d. enable implicit flow and grant permission.

ashuetawah avatar May 02 '18 07:05 ashuetawah

cc: @VesaJuvonen @patmill @waldekmastykarz

ashuetawah avatar May 02 '18 10:05 ashuetawah

So, this is using code from 1-2 years ago from the looks of things. You should look into using the new feature work around accessing AAD protected APIs. Take a look at this tutorial - it shows accessing MSGraph, but it should apply to your own end points as well (you'll just need to use the AAD http client, rather than the MSGraph one.)

https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aad-tutorial

patmill avatar May 03 '18 16:05 patmill

@patmill, on twitter @ashuetawah mentioned that he needs a solution that's supported in production (https://twitter.com/_AshishTrivedi/status/991973438792253441). AadHttpClient is currently in preview which is why he used his own implementation of ADAL JS instead.

waldekmastykarz avatar May 03 '18 17:05 waldekmastykarz

@patmill yes, I am writing code for production release and I am not aware on any GA lines for AadHttpClient. I got it resolved by looking up Azure Git repo issues and changing Office ui fabric button to a html button type. It is strange that we support office ui fabric and the controls does not work well in SPFx.

ashuetawah avatar May 04 '18 15:05 ashuetawah

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 27 '20 18:01 msft-github-bot