manishrasrani / ms-adal-angular6

This is a wrapper library for Angular 6+ (Angular 6.X.X and Angular 7.X.X) modules over Microsoft ADAL (Azure Active Directory Authentication Library)
https://www.npmjs.com/package/microsoft-adal-angular6
MIT License
34 stars 13 forks source link

Issue in generating token from ms-adal-angular6 package to authenticate powerbi report #44

Open Ananya-96 opened 3 years ago

Ananya-96 commented 3 years ago

I am using Angular 8, ms-adal-angular6 package for Login and ngx-powerbi package to embed Powerbi report

I have created Azure App Registration and given the Powerbi API permissions

image

I am using the below configurations for Azure AD login

{ tenant: 'my tenant id', clientId: 'my client id', redirectUri: 'http://localhost:4200', navigateToLoginRequestUrl: false, cacheLocation: 'localStorage', postLogoutRedirectUri: 'http://localhost:4200', tokenUrl: 'https://graph.microsoft.com', resource: 'https://analysis.windows.net/powerbi/api', expireOffsetSeconds: 15 * 60 }

And I try to embed the powerbi report using the below code

<ngx-powerbi-component
    type="report"
    id="my-report-id"
    embedUrl="https://app.powerbi.com/reportEmbed?reportId=my-report-id&groupId=my-group-id"
    tokenType="Aad"
    [accessToken]="token from ADAL"
  ></ngx-powerbi-component>

I have enabled service principal access in powerbi side

But still I am getting

image

If I generate AD token from Postman with

GET https://login.microsoftonline.com/vca.com/oauth2/token grant_type=password&client_id=[my_client_id]&client_secret=[my_client_secret]&resource=https://analysis.windows.net/powerbi/api&username=[username]&password=[password]

and use the response token in the ngx-powerbi-component, I am able to view the report.

I am not able to figure out how to generate correct AD token from MS ADAL.