Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
TomMartens
Super User
Super User

connect to Power BI Service using R

Hey for quite some time I'm trying to connect to the Power BI Servvice using the R package httr. Until now without any success.

 

I'm trying to get an access token for further use ...

 

Currently my R code looks like this

library("httr");
library("httpuv")


powerbi.urls <- oauth_endpoint(
NULL,  
"authorize",  
"token",
base_url = "https://login.windows.net/common/oauth2")

powerbi.app <- oauth_app(
"myAppName",
key="myClientID", 
secret="myClientSecret"
)

powerbi.token <- oauth2.0_token(powerbi.urls, powerbi.app)
powerbi.token

The package httpuv is just used to provide a local web server using port 1410.

 

I used this page

https://dev.powerbi.com/apps?type=web

to create a client-id and a client-secret for a web-app "myAppname".

 

I'm aware of the documentation how to connect to the Power BI Service and also aware of this site

https://www.codeproject.com/tips/1042542/connecting-to-power-bi-rest-api-from-a-service-i-e

 

But I'm not able to translate the C# examples to the proper parameter for the httr functions.

 

I'm able to connect to linkedin and git using httr, but not to the Power BI Service

 

For this reason, any help is much appreciated, even direct comments like

  • This will never work, due to ...
  • Stupid you, just do this ...


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Ha, if you think a little longer and then you change your code a little and it works Smiley Very Happy

 

library("httr");
library("httpuv")

# 
#oauth_endpoints("azure")
powerbi.urls <- oauth_endpoint(  
"authorize",  
"token",
base_url = "https://login.windows.net/common/oauth2")

powerbi.app <- oauth_app(
"myAppName",
key="myClientID", 
secret="myClientSecret"
)

powerbi.token <- oauth2.0_token(powerbi.urls, powerbi.app,
                          user_params = list(resource = "https://analysis.windows.net/powerbi/api"),
                          use_oob = FALSE)


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Ha, if you think a little longer and then you change your code a little and it works Smiley Very Happy

 

library("httr");
library("httpuv")

# 
#oauth_endpoints("azure")
powerbi.urls <- oauth_endpoint(  
"authorize",  
"token",
base_url = "https://login.windows.net/common/oauth2")

powerbi.app <- oauth_app(
"myAppName",
key="myClientID", 
secret="myClientSecret"
)

powerbi.token <- oauth2.0_token(powerbi.urls, powerbi.app,
                          user_params = list(resource = "https://analysis.windows.net/powerbi/api"),
                          use_oob = FALSE)


Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens,

 

I've tried this approach with the same R code, but I'm receiving a below error in a browser:

Sign in
Sorry, but we’re having trouble signing you in.

AADSTS50011: The reply url specified in the request does not match the reply urls 
configured for the application: 'value for clientID'.

Is it working today from your side?

 

Regards,

Ruslan

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.