Get Power BI access token

To get Power BI access token by grand type password, use the bellow code

public async Task<OAuthResultDto> GetAccessTokenAsync()
	var oauthEndpoint = new Uri("");

	using (var client = new HttpClient())
		var result = await client.PostAsync(oauthEndpoint, new FormUrlEncodedContent(new[]
			new KeyValuePair<string, string>("resource", ""),
			new KeyValuePair<string, string>("client_id", "1638c1dd-xxxx-4444-xxxx-xxxx4444xxxx"),
			new KeyValuePair<string, string>("grant_type", "password"),
			new KeyValuePair<string, string>("username", "username"),
			new KeyValuePair<string, string>("password", "password"),
			new KeyValuePair<string, string>("scope", "openid")

		var content = await result.Content.ReadAsStringAsync();                
		var deserilized = JsonConvert.DeserializeObject<OAuthResult>(content);
		return deserilized;

Details about above method:

oauthEndpoint : Authorization will happen here
resource: Resource URI
client_id: Client Id or Application Id, which can be obtain from Azure Active directory by creating an application.
grant_type: It is type of authentication
username: User name register with Power BI
password: User Password
scope: Scope

public class OAuthResult
	public string TokenType { get; set; }
	public string Scope { get; set; }
	public int ExpiresIn { get; set; }
	public int ExtExpiresIn { get; set; }
	public int ExpiresOn { get; set; }
	public int NotBefore { get; set; }
	public string Resource { get; set; }
	public string AccessToken { get; set; }
	public string RefreshToken { get; set; }
	public string TokenId { get; set; }

16 thoughts on “Get Power BI access token”

  1. The solution that I found recommended online for ASP.Net core is to use a tag helper however now that the Power BI Embedded and Power BI service have converged with the new arrival of Power BI Premium I dont think think this solutions is possible due to the depencency on token authentication for the App Hosted data.

  2. I’m really enjoying the theme/design of your weblog. Do you ever run into any web browser compatibility problems? A couple of my blog visitors have complained about my website not working correctly in Explorer but looks great in Firefox. Do you have any ideas to help fix this problem?

  3. Attractive section of content. I just stumbled upon your website and in accession capital to assert that I acquire actually enjoyed account your blog posts. Anyway I’ll be subscribing to your feeds and even I achievement you access consistently fast.

  4. Magnificent beat ! I wish to apprentice while you amend your web site, how can i subscribe for a weblog website? The account helped me a acceptable deal. I have been tiny bit familiar of this your broadcast provided brilliant transparent concept|

  5. Hello! This post could not be written any better! Reading through this post reminds me of my old room mate! He always kept chatting about this. I will forward this article to him. Fairly certain he will have a good read. Thank you for sharing!|

  6. Hey there, I think your website might be having browser compatibility issues. When I look at your blog site in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, amazing blog!

  7. I’m no longer certain the place you’re getting your information, however good topic. I needs to spend a while studying more or figuring out more. Thanks for fantastic information I was looking for this information for my mission.|

  8. If some one needs to be updated with newest technologies afterward he must be pay a quick visit this web page and be up to date daily.|

  9. I’m not sure exactly why but this blog is loading incredibly slow for me. Is anyone else having this problem or is it a issue on my end? I’ll check back later on and see if the problem still exists.|

  10. Greetings from Carolina! I’m bored at work so I decided to browse your website on my iphone during lunch break. I enjoy the info you present here and can’t wait to take a look when I get home. I’m shocked at how fast your blog loaded on my mobile .. I’m not even using WIFI, just 3G .. Anyways, fantastic blog!|

  11. Undeniably consider that which you said. Your favourite reason seemed
    to be at the internet the simplest factor to consider of. I say to you,
    I definitely get irked even as other people
    consider concerns that they plainly do not understand about.
    You managed to hit the nail upon the highest and outlined out the whole thing
    with no need side effect , folks could take a signal.
    Will probably be again to get more. Thank you

  12. Excellent blog here! Also your website loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my web site loaded up as fast as yours lol|

Leave a Reply

Your email address will not be published. Required fields are marked *