Embed Power BI Report in a single page app for organisation users - reactjs

I am trying to embed the Microsoft Power BI report into the react app. As per the documentation, for embedding and accessing the Power BI Rest APIs we need to register an Azure Active Directory App.
As we already have an Azure AD app that we are using for single sign-on I tried to add scope for report access. But I am not getting any success
I added "https://analysis.windows.net/powerbi/api/Report.Read.All" scope in my msal config but it's not working
Can't we use the same APP (Already used for SSO) for accessing POWER BI?
This is the article that I am following
https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-your-organization?tabs=net-core
Thank you

Related

PowerBIEmbed with loggedin user authorization

I am developing one react application to show power bi reports on one of my app pages.
i am using 'powerbi-client-react' npm client to include the report by giving the report URL. But previously I was using my dev account to see the embedded powerbi. But once i go for live testing, the clients can't see their reports because I was using accessTokenKey from my dev account statically.
Now I wanted it to work for all of my customers with their login and show their reports inside my app.
What i need to do to implement the autorization to show powerbi report?
What i need to do to implement the autorization to show powerbi report?
For using embed power Bi for your customers or for your organization you can use either Azure AD token or Embed token.
In rest api you need to have Azure AD token. which will expire for every hour.
For the customers Azure AD token is used to generate Embed token.
While using Embed Tokens you need to specify which content can the customer access and also their access level.
Here are the authentication flows for embed token generation for customers.
Below image represents the authentication flows of Embed token for your customers.
Refer this Microsoft Document for complete information regarding Embed Token for customers.
https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-tokens?tabs=embed-for-customers#embed-token

Sharepoint WebPart with Graph API

Is there a way to use Sharepoint Framework Client side Webpart to use on classic Sharepoint Page ? I want to use Graph API. and it looks like i can use that using SpFx (without Azure AD App) but wondering if SpFx webpart can be added on classic SharePoint page (Project Online).
Also, I do not want to create Azure AD App to acquire access token and then use Graph APIs.
It looks like I have only following options:
Option 1: Use SpFx to create Webpart to use Graph API without registering App to Azure
Option 2: Use Azure AD App to access graph api access token and then use that token hit APIs
Is there anything else i can do ? 😁
SPFx web parts can be added to both classic and modern pages. See here: SPFx web parts can be added to both classic and modern pages.
And by using SharePoint Framework, you don't need to explicitly create Azure Active Directory applications to manage your permissions for your solutions.istead, you can request the needed permissions in your solution package, and Microsoft 365 tenant administrator can then grant the requested permissions in general for all solutions or for this specific solution (isolated solution). Read this article for more: https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis

Do I need an Azure AD app to embed my Power BI reports in my own app?

I'm confused about the guideline I have to follow to embed some Power BI reports in a react app. I've been reading this documentation but I don't understand why I need an Azure AD app. By now I've created four Power BI reports and I've published them to the web (making them public and accessible for everyone). So, I've got four PBI links to access them. But I want to create a web app (probably with React) to embed them all in one link.
I understand that Azure covers authentication features, but my app will only show information, doesn't need users to log in or something. So, I guess Azure helps to authenticate to the PBI account I'm using. But if this is the case, why PBI doesn't ask me for authentication when I share the reports links with anyone?
Thank you in advance!
You need Azure AD app to have identity for your application, to authenticate to Azure AD (using MSAL for example) and for using the Power BI REST APIs. Check the following article: https://learn.microsoft.com/en-us/power-bi/developer/embedded/register-app
Since you are already logged in you don't need to login to PowerBi again, There are two ways to embed your PowerBI reports,
Publish to web -> Does not require authentication (Public reports)
Embed with authentication -> Hyperlink and token based ( Requires Azure AD)
You can check more information here

Office Add-In SSO with an AAD v1 app registration

I am developing a office add-in.
This office Add-In is supposed to retrieve the term store from SharePoint.
By following this tutorial:
https://learn.microsoft.com/en-us/office/dev/add-ins/develop/create-sso-office-add-ins-aspnet
I managed to get an access token to be used for Graph api. However the Graph does not expose any way of getting the term store. Is there a way we can generate an access token to be used with SharePoint and maintain the SSO?
It might be possible by registering an Azure AD v1 app but I could not find any documentation describing that.
I have a similar requirement, but in my research I wasn't able to find a good solution for this scenario.
I think it is probably possible to use a provider hosted SharePoint add-in. And then use the Authorization Code flow for obtaining an access token. Since the SharePoint add-in is trusted it will not require user login.
Of course this does mean the add-in needs to be deployed in SharePoint. If your Office add-in is distributed through the store this isn't really a great solution.
Hopefully there are other ways of achieving the same.
You could call SharePoint Online APIs (via REST or CSOM) with Azure Active Directory Apps. To call APIs secured by Azure AD, your app must acquire an access token from Azure Active Directory.
Please first refer to this document for integrating applications with Azure Active Directory. Then use Azure Active Directory Authentication Library (ADAL) to easily authenticate users to cloud or on-premises Active Directory (AD), and obtain access tokens for securing API calls.

Accessing Office Graph apis with Sharepoint Online login?

We've been running an Angular app in a custom masterpage during the last year, using the Sharepoint REST api to retrieve user properties, data from lists etc., which has been working fine. As the application is hosted on Sharepoint Online, accessing the page requires a login thus making the request digest available so further authentication is not necessary.
Now however, we want to start using some of the functionality in the Microsoft Graph API. From what I can gather this requires OAuth2 authentication against the Azure Active Directory, involving among other things a redirect to the AAD login page.
Does this mean I have to:
1) Login via the organizations (standard Microsoft) login page to access the Sharepoint Online site.
2) Redirect to the Azure AD login page and back again?
Or can I leverage the login that the user already did when logging into Sharepoint Online?
Sorry if the question is a bit vague, we are all still very new to this.
When registering your application on Azure AD you will give the app access to Files/Sharepoint REST api and Microsoft Graph API. See this picture the app has access to several apis (Exchange, Graph and AD) you must add sharepoint APIs in your case.
Regarding the authentication, I am afraid that the Sharepoint model does not provide a token that will enable you to request the Graph API see this. You will have two authentications, one to access the Sharepoint site, as you said, and the other "within" the sharepoint iframed add-in to log into your AAD's registered app. This will be an OAUTH process through login.microsoft.com. Have a look at my Outlook add-in Keluro Mail Team on the Office store, I think it is similar to what you want to achieve.
You can use the same token from graph.microsoft.com. I have a sample using Asp.Net Core 1.0 and the.Net ADAL but the same authentication flow is used when using ASP.NET 4.6. Just make your auth request against ms graph on startup then acquire access token to auth against SharePoint.
https://github.com/edrohler/com.ericrohler
Hope this helps.

Resources