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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Polly
Helper I
Helper I

Using the R script in PowerBI to connect to spotify via Rspotify Package - issue with OAuth

Hey,

 

I wonder if anyone can help

 

I am trying to run a function which leverages the RSpotify package. It works with no problems within R studio, however, it seems to have issue authorising when I try to run it in the PowerBI R scripter. I wonder if anyone has had a similar issue or has any suggestions?

Error Message: R script error. Error in httpuv::startServer(use$host, use$port, list(call = listen)) : Failed to create server Calls: Check_Genre ... init_oauth2.0 -> oauth_authorize -> oauth_listener -> Execution halted

My Function

ArtistName <- dataset$ArtistName[1] library(devtools) library(Rspotify)

Check_Genre <- function(ArtistName) {

   ClientID <- "********************"    Client_Secret <- "********************"
    keys <- spotifyOAuth("RSpotify_Project", ClientID, Client_Secret) 



   ArtistName <- as.vector(ArtistName)   artist_info <-  length(ArtistName)



   for(i in 1:length(ArtistName)){    ifelse(length(searchArtist(ArtistName[i], token = keys))>=1,       
           artist_info[i] <- searchArtist(ArtistName[i], token = 
                keys)$genres[1],                   artist_info[i] <- "")

  }   artist_info
     }      Genre <- Check_Genre(ArtistName)      library(wordcloud)       library(tm)     wordcloud(Genre, random.order = FALSE)

Thanks,

Polly

1 ACCEPTED SOLUTION

Hey,

 

and you should also be aware, that the Power BI Service does not allow to reach out to "foreign" web ressources. So, whatever you do with the Spotify data, the data has to be gathered locally and then published to the Power BI service manually.

 

There will be no way to configure an automatic refresh that allows running an RScript sourcing  a "foreign" web ressource.

 

Regards

Tom



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

4 REPLIES 4
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi Polly,

 

According to my test, the OAuth2 seems needing user interaction. However, Power BI Desktop will halt the R scripts if interactive calls happen. Please refer to desktop-r-scripts#prepare-an-r-script.

>>>Interactive calls in the R script, such as waiting for user input, halts the script’s execution

 

I wonder if this post could help.

 

Using_the_R_script_in_Power_BI_to_connect_to_spotify_via_Rspotify_Package

 

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.

Hey Dale,

 

Ah that's what I feared!

 

Thanks for your response I'll read the post post and see if I can get it to work

 

Thanks,

 

Polly

Hey,

 

and you should also be aware, that the Power BI Service does not allow to reach out to "foreign" web ressources. So, whatever you do with the Spotify data, the data has to be gathered locally and then published to the Power BI service manually.

 

There will be no way to configure an automatic refresh that allows running an RScript sourcing  a "foreign" web ressource.

 

Regards

Tom



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

Thanks guys

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.