Forum Discussion

SYang89's avatar
SYang89
Copper Contributor
Mar 21, 2024

Could not get data from web that uses Azure AD authentication

More details please see here: https://learn.microsoft.com/en-us/answers/questions/1611550/could-not-get-data-from-web-using-azure-ad-authent.
Any help would be greatly appreciated. Thanks in advance. 

4 Replies

  • peiyezhu's avatar
    peiyezhu
    Bronze Contributor

    It works perfectly in browser and provides REST APIs that return JSON data.


    Can you show the detail about this success implement of RESTful Api?

    Can we trouble shooting on it?

    • SYang89's avatar
      SYang89
      Copper Contributor

      peiyezhu 

      As you can see from the documentation here (https://learn.microsoft.com/en-us/power-query/connector-authentication), it reads "When you select Sign-in in Step 2 above, Power Query sends a request to the provided URL endpoint with an authorization header with an empty bearer token. The service is then expected to respond with a 401 response with a WWW-Authenticate header indicating the Microsoft Entra ID authorization URI to use. Power Query can then initiate the OAuth flow against the authorization_uri. Power Query requests a Microsoft Entra ID Resource or Audience value equal to the domain of the URL being requested. This value would be the value you use for your Azure Application ID URL value in your API/service registration."

       

      You know, the sign in step was completed successfully. The next step, where power query initiate the OAuth flow against the authorization_uri, should be executed automatically and implicitly, if I understand correctly. But I got the error. It seams that power query for excel got an access token with a wrong audience value from the authorization_uri (https://login.microsoftonline.com/{tenant_id}/oauth2/authorize).

       

      I have tried https://login.microsoftonline.com/%7Btenant_id%7D/oauth2/authorize?client_id=%7Bclient_id%7D&response_type=code&redirect_uri=%7Bredirect_uri%7D&response_mode=query&resource=%7Bresource_id%7D&state=%7Bstate%7D and still got the same error. How to get the right audience then?

Resources