1

I have created an angular-adal SPFx project, now when I'm trying to acquire the token. It always displays a message:

Token renewal operation failed due to timeout

adal.acquireToken("Dynamic 365 API", (error, token)=>{

console.log("error");

});

EDIT

After using the inbuilt spfx AadHttpClient, the issue which I am Facing.

Error: The requested operation is part of an experimental feature that is not supported in the current environment.

Code

this.context.aadHttpClientFactory.getClient('https://tenant.onmicrosoft.com/{ApplicationId}').then((client: AadHttpClient): void => {
    client.get('https://graph.microsoft.com/v1.0/me', AadHttpClient.configurations.v1).then((response: HttpClientResponse): Promise<JSON> => {
      debugger;
      return response.json();
    })
    .then((responseJSON: JSON): void => {

      debugger;
      var claimsTable = this.domElement.getElementsByClassName("azFuncClaimsTable")[0];
      for (var key in responseJSON) {
        var trElement = document.createElement("tr");
        // trElement.innerHTML = `<td class="${styles.azFuncCell}">${key}</td><td class="${styles.azFuncCell}">${responseJSON[key]}</td>`;
        claimsTable.appendChild(trElement);
      }
    });
  });

Line where error comes

client.get('https://graph.microsoft.com/v1.0/me', AadHttpClient.configurations.v1).then((response: HttpClientResponse): Promise<JSON> => {

Image Description

Error: The requested operation is part of an experimental feature that is not supported in the current environment.

Thanks for the help!

4

If possible, I recommend you to upgrade your solution to the latest SPFx 1.6 version and get rid of adal.js in your code. Read here more about the release and how to upgrade your solution.

Why I suggest moving to 1.6:

  • adal.js inside SPFx has lots of caveats you should be aware of. You should implement everything by yourself, which might be error prone because of complexity
  • SPFx 1.6 introduced new helper classes for such things as Azure AD authentication. Please read this article to learn, how to send authenticated http requests to your API with SPFx 1.6. It's not surprise, that internally Microsoft uses adal.js, however they use patched version, which works smoothly

This great article by @Vardhaman Deshpande contains a very good sample on how to call Azure AD protected API hosted as Azure function with SPFx 1.6 features.

  • Can I call this API: https://graph.microsoft.com/v1.0/me? – Utkarsh Dubey Sep 11 '18 at 11:14
  • Sure, you can call it – Sergei Sergeev Sep 11 '18 at 11:16
  • Please! check my edits. – Utkarsh Dubey Sep 12 '18 at 7:01
  • Since you need MS Graph, then please use GraphClient which is even simpler. If you see "experimental feature", please follow these steps (comment) to resolve it – Sergei Sergeev Sep 12 '18 at 7:18
  • also please make your user and administrator and admin site collection, for that purpose follow these steps – Sergei Sergeev Sep 12 '18 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.