“No method available for opening” – trying to authenticate google sheets in R on Linux Ubuntu

Solution for “No method available for opening” – trying to authenticate google sheets in R on Linux Ubuntu
is Given Below:

We have an R script that we are scheduling to run daily with cron, and need to authenticate with Google Sheets.

> gs4_auth(path="/path-to/our-service-account-key.json")

Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 870: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'https://accounts.google.com/o/oauth2/auth?client_id=... ... ...'

Do we simply need to install one of www-browser, links2, elinks, etc. on our Linux server?

Edit: We’ve installed a few of these tools, and now when we run gs4_auth from on the Ubuntu server we get:

> gs4_auth(path="path-to/our-service-account-key.json")

Waiting for authentication in browser...
Press Esc/Ctrl + C to abort

From the Linux server, we still do not know how to authenticate in browser… I thought the point of the service-account key was so that manually authenticating in browser was not needed. There is no prompt to manually authenticate when we run gs4_auth(path="path-to/our-service-account-key.json") locally in RStudio…

Edit2: We’ve reached a point now where we (a) CAN run our R script on the Linux server with Rscript our_file.R, BUT when we try to schedule it with cron, it still throws an error at the authentication part of the code…