cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
zoloturu
Advisor

How to generate authorization token in R?

Dear community,

 

I'm trying to generate an authorization token to Power BI Service in R. Thanks to Tom Martens there is his experience mentioned in this topic - https://community.powerbi.com/t5/Service/connect-to-Power-BI-Service-using-R/m-p/119697#M18632

 

When I tried, it was unsuccessful. Can somebody help to find out what is wrong in below R script?

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="my_client_id-value", 
  secret="my_secret_id-value"
)

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

Regards,

Ruslan

 

 

 

5 REPLIES 5
v-jiascu-msft Super Contributor
Super Contributor

Re: How to generate authorization token in R?

Hi Ruslan,

 

What's the error message? 

I added a parameter to "oauth_endpoint". It worked. Please give it a try.

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

# 
#oauth_endpoints("azure")
powerbi.urls <- oauth_endpoint(
NULL, "authorize", "token", base_url = "https://login.windows.net/common/oauth2") powerbi.app <- oauth_app( "myAppName", key="my_client_id-value", secret="my_secret_id-value" ) powerbi.token <- oauth2.0_token(powerbi.urls, powerbi.app, user_params = list(resource = "https://analysis.windows.net/powerbi/api"), use_oob = FALSE)

How_to_generate_authorization_token_in_R

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
zoloturu
Advisor

Re: How to generate authorization token in R?

Hi Dale @v-jiascu-msft,

 

I've tried with your addition. But error persists. See it below:

 

r error auth.PNGbrowser error

Regards,

Ruslan

 

v-jiascu-msft Super Contributor
Super Contributor

Re: How to generate authorization token in R?

Hi Ruslan,

 

As we can see from the error message, it seem the redirect URL isn't the same between your settings and the Azure settings. Please refer to the snapshot below and check out.

How_to_generate_authorization_token_in_R2

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft Super Contributor
Super Contributor

Re: How to generate authorization token in R?

Hi @zoloturu,

 

Could you please mark the proper answer as a solution?

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
zoloturu
Advisor

Re: How to generate authorization token in R?

Hi Dale @v-jiascu-msft,

 

I didn't receive any solution so far. I tried to add localhost in Azure portal to app registrations as you told, but it didn't help. I opened a MS ticket for that. You can check it with number 118071418582124.

 

Regards,

Ruslan

Helpful resources

Announcements
Community Highlights

Community Highlights

Find out what's new in the Power BI Community!

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 375 members 4,065 guests
Please welcome our newest community members: