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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
lindajzmin
Frequent Visitor

Error connecting to Google Search Console API in Power BI using R script

 

Hi everyone,

I am trying to connect to the Google Search Console API using an R script in Power BI. I have successfully done this before with the Google Ads API and the Google Analytics 4 API, so I have the necessary Google permissions and authentication.

This time, I have added the permissions in the Google Search Console domain, but I am getting the following error, which I find strange because the code works perfectly in R. Does anyone know if I need any special permissions in Power BI?

 

Details

  • Error message:

ADO.NET: Script R error. Fetching search analytics for url: https://wwwxxxxxxxxxx/ dates: 2023-01-01 2023-01-31 dimensions: country dimensionFilterExp: searchType: web aggregationType: auto 2024-02-14 13:33:54.523797 > Request Status Code: 403 Error in `abort_http()`: ! http_403 Request had insufficient authentication scopes. Backtrace: 1. searchConsoleR::search_analytics(...) 2. googleAuthR (local) search_analytics_g(...) 3. googleAuthR:::doHttrRequest(...) 4. googleAuthR:::retryRequest(...) 5. googleAuthR:::abort_http(status_code, error) 6. rlang::abort(...) Execution interrupted

 

 

Additional information:

  • I have already successfully connected to the Google Ads API and Google Analytics 4 API using R scripts in Power BI.
  • I have added the necessary permissions for the Google Search Console API in the Google Cloud Platform Console.
  • The R script works perfectly when I run it in RStudio.

Any help or suggestions would be greatly appreciated.

Thanks in advance,

Linda

P.S. I have also attached the R script for your reference.

R script:

 

library(searchConsoleR)
library(googleAuthR)

 

options(googleAuthR.scopes = c("https://www.googleapis.com/auth/webmasters"))

gar_auth_service("C:/Users/linda/OneDrive/Documentos/xxxxxx.json")

 

gsc <-
search_analytics(siteURL = "https://www.xxxxxxxx.xx/",
startDate = "2023-01-01",
endDate = "2023-01-31",
dimensions = "country",
searchType = "web",
rowLimit = 5000)

3 REPLIES 3
CoderZen08
Helper III
Helper III

Hi @lindajzmin were you able to find a solution? As a workaround, maybe you can try to test your connection with a 3rd party connector. I currently use windsor.ai 's Search console connector and I haven't had any problem with my data. In case you wonder, to make the connection first search for the GSC connector in the data sources list:

 

SEARCH-CONSOLE1.png

 

After that, just grant access to your GSC account using your credentials, then on preview and destination page you will see a preview of your GSC fields:

 

SEARCH-CONSOLE2.png

 

There just select the fields you need. Finally, just select PBI as your data destination and finally just copy and paste the url on PBI --> Get Data --> Web --> Paste the url.

 

SELECT_DESTINATION_NEW.png

Thank you very much for your help, but first I will try with R because it is free, and then if it doesn't work, I will switch to windsor.ai... But your suggestion is very valuable.

v-xinruzhu-msft
Community Support
Community Support

Hi @lindajzmin 

Please make sure that your connection  is right, and maybe you can consider to use 'Web' connector and the api to conect to the google search console. there is a similar thread , you can refer to it.

Solved: Integrate Google Search Console API into Power BI - Microsoft Fabric Community

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors