Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 17884

SSO to powerBI REST API from Azure Web App or SharePoint Provider Hosted Add In

$
0
0

Hi,

   I am accessing the powerBI dashboards and reports using REST API calls. My application will be Azure Web App or SharePoint provider hosted add in with Azure AD authentication enabled.

  I need to authenticate user credentials to poewrBI REST API without additional popup. User will login to webapp/sharepoint addin and further they shouldn't be prompted for login.

 

At present I am using this code to authenticate user which pops for user name and password.

 

protected void signInButton_Click(object sender, EventArgs e)
{
//Create a query string
//Create a sign-in NameValueCollection for query string
var @params = new NameValueCollection
{
//Azure AD will return an authorization code.
//See the Redirect class to see how "code" is used to AcquireTokenByAuthorizationCode
{"response_type", "code"},

//Client ID is used by the application to identify themselves to the users that they are requesting permissions from.
//You get the client id when you register your Azure app.
{"client_id", Properties.Settings.Default.ClientID},

//Resource uri to the Power BI resource to be authorized
{"resource", Properties.Settings.Default.PowerBiAPI},

//After user authenticates, Azure AD will redirect back to the web app
{"redirect_uri", "http://localhost:13526/Redirect"}
};

//Create sign-in query string
var queryString = HttpUtility.ParseQueryString(string.Empty);
queryString.Add(@params);

//Redirect authority
//Authority Uri is an Azure resource that takes a client id to get an Access token
string authorityUri = Properties.Settings.Default.AADAuthoritySignInUri;
var authUri = String.Format("{0}?{1}", authorityUri, queryString);
Response.Redirect(authUri);
}

 

Regards,

Yasotha


Viewing all articles
Browse latest Browse all 17884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>