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
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 IV
Helper IV

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
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.

Top Solution Authors