Send an interactive authorization request for this user and resource.

%3CLINGO-SUB%20id%3D%22lingo-sub-1091867%22%20slang%3D%22en-US%22%3ESend%20an%20interactive%20authorization%20request%20for%20this%20user%20and%20resource.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1091867%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETrying%20to%20get%20an%20access%20token%20for%20an%20app%20registration%20using%20aadTokenProvider%20and%20getting%20this%20error.%3C%2FP%3E%3CP%3EConsented%20the%20registration%20multiple%20times%20in%20Azure%20itself%20and%20through%20the%20consent%20screen.%3C%2FP%3E%3CP%3EKeep%20getting%20this%20error%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163876i1E47DEA80484C549%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECode%3A%3C%2FP%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%20%20%20%20this.props.context.aadTokenProviderFactory.getTokenProvider().then((tokenProvider)%20%3D%26gt%3B%20%7B%0A%20%20%20%20%20%20return%20tokenProvider.getToken('XXXXXXXX')%3B%0A%20%20%20%20%7D).then((token%3A%20string)%20%3D%26gt%3B%20%7B%0A%20%20%20%20%20%20alert(token)%3B%0A%20%20%20%20%7D).catch(err%20%3D%26gt%3B%20%7B%0A%20%20%20%20%20%20console.log(err)%3B%0A%20%20%20%20%7D)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1091867%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%20SharePoint%20SPFx%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1093587%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20interactive%20authorization%20request%20for%20this%20user%20and%20resource.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1093587%22%20slang%3D%22en-US%22%3EFollow%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure-Samples%2Factive-directory-angularjs-singlepageapp-dotnet-webapi%2Fissues%2F19%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure-Samples%2Factive-directory-angularjs-singlepageapp-dotnet-webapi%2Fissues%2F19%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2Fsp-dev-docs%2Fissues%2F3102%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2Fsp-dev-docs%2Fissues%2F3102%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1095094%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20an%20interactive%20authorization%20request%20for%20this%20user%20and%20resource.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1095094%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F494951%22%20target%3D%22_blank%22%3E%40dhaeseleermatthias%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBased%20on%20image%20you%20posted%2C%20it%20looks%20like%20your%20AD%20app%20is%20not%20consented%20by%20user%20or%20Admin%20on%20behalf%20of%20user.%20Admin%20can%20consent%20Azure%20AD%20app%20on%20behalf%20of%20user.%20Make%20sure%20your%20app%20is%20consented.%20If%20your%20app%20needs%20user%20consent%2C%20you%20can%20create%20user%20consent%20URI%20like%20below%20(replace%20appropriate%20tokens%20based%20on%20your%20Azure%20AD%20app%20registration)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2F%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Flogin.microsoftonline.com%2F%3CTENANT_ID%3E%2Foauth2%2Fv2.0%2Fauthorize%3Fclient_id%3D%3CCLIENT_ID%3E%26amp%3Bresponse_type%3Dcode%26amp%3Bredirect_uri%3D%3CAD_APP_REDIRECT_URI%3E%26amp%3Bresponse_mode%3Dquery%26amp%3Bscope%3D%3CAD_APP_PERMISSION_SCOPE%3E%26amp%3Bstate%3D12345%3C%2FAD_APP_PERMISSION_SCOPE%3E%3C%2FAD_APP_REDIRECT_URI%3E%3C%2FCLIENT_ID%3E%3C%2FTENANT_ID%3E%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,

 

Trying to get an access token for an app registration using aadTokenProvider and getting this error.

Consented the registration multiple times in Azure itself and through the consent screen.

Keep getting this error:

 

clipboard_image_0.png

 

Any help?

 

Code:

 

 

    this.props.context.aadTokenProviderFactory.getTokenProvider().then((tokenProvider) => {
      return tokenProvider.getToken('XXXXXXXX');
    }).then((token: string) => {
      alert(token);
    }).catch(err => {
      console.log(err);
    });

 

2 Replies

@dhaeseleermatthias 

 

Based on image you posted, it looks like your AD app is not consented by user or Admin on behalf of user. Admin can consent Azure AD app on behalf of user. Make sure your app is consented. If your app needs user consent, you can create user consent URI like below (replace appropriate tokens based on your Azure AD app registration)

 

https://login.microsoftonline.com/<tenant_ID>/oauth2/v2.0/authorize?client_id=<Client_ID>&response_t...