Skip to content

AadHttpClient - User login is required #1810

@vocaris

Description

@vocaris

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

After reading the articel https://docs.microsoft.com/de-de/sharepoint/dev/spfx/use-aad-tutorial I tried to implement the AadHttpClient to query the Azure AD. Everything works fine while development but now we try to set the solution to productive.

Observed Behavior

We get the following error at the browsers console window:

Error

columnNumber: 33832

fileName: "https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.025/sp-pages-assembly_de-de_fe39afc9a02d6a7fc3dec634a0dd4931.js"

lineNumber: 592

message: "User login is required"
​>
stack: "WEBPACK_AMD_DEFINE_RESULT</</ye</e.prototype.acquireTokenPromise/</<@https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.025/sp-pages-assembly_de-de_fe39afc9a02d6a7fc3dec634a0dd4931.js:592:33832\n[6]/i</i.prototype.acquireToken@https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.025/0.sp-http-adal_4a41848c866052caa755.js:3:11368\n__WEBPACK_AMD_DEFINE_RESULT_</</ye</e.prototype.acquireTokenPromise/<@https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.025/sp-pages-assembly_de-de_fe39afc9a02d6a7fc3dec634a0dd4931.js:592:33400\n__WEBPACK_AMD_DEFINE_RESULT_</</ye</e.prototype.acquireTokenPromise@https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.025/sp-pages-assembly_de-de_fe39afc9a02d6a7fc3dec634a0dd4931.js:592:33262\n__WEBPACK_AMD_DEFINE_RESULT_</</ye</e.prototype.getToken/<@https://spoprod-a.akamaihd.net/files/sp-client-prod_2018-04-27.025/sp-pages-assembly_de-de_fe39afc9a02d6a7fc3dec634a0dd4931.js:592:32853\n"`

Steps to Reproduce

We extracted the Azure AD related functions into a seperate TypeScript-Class like the following:

export default class AzureAdHelper{
constructor(context: WebPartContext){
this._aadClient = new AadHttpClient(context.serviceScope, "https://graph.microsoft.com");
}
private _aadClient: AadHttpClient;

The error occurs inside the following method while we trying to load users. The URL Parameter is filled with: https://graph.microsoft.com/beta/users?top=100&$filter=department eq 'BU-1' or Department eq 'BU-2'

private _singleSearchCallWithAad(url:string):Promise{
return new Promise((resolve: (result: any) => void, reject: (error: any) => void) : void => {
this._aadClient
.get(url, AadHttpClient.configurations.v1)
.then(response => {
resolve(response.json());
})
.catch(error => {
console.error(error);
});
});
}`

Why we get the "User Login is required". I understood the AadHttpClient that it will handle the users Login process for me? Where is my mistake?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:spfxCategory: SharePoint Framework (not extensions related)status:fixedIssue was fixed in current or prior release.status:trackedCurrently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed)type:bug-confirmedConfirmed bug, not working as designed / expected.type:questionQuestion... if answered, will be tagged as such.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions