How to Authenticate for Google Analytics on AWS UBUNTU without browser

I have been pulling Google Analytics metrics using the following code in R on my local machine

library(RGoogleAnalytics) 
client_id <- " " 
client_secret <- " " 
oauth_token <- Auth(client_id,client_secret) 
save(oauth_token, file="oauth_token") 
load("oauth_token") 
GetProfiles(oauth_token) 
query.init<-Init()

It prompts to authenticate only for the first time.

Similarly, when i try to pull Google Analytics metrics with same code in R on AWS UBUNTU instance, it prompts the following:

Waiting for authentication in browser... Press Esc/Ctrl + C to abort Please point your browser to the following url:

How do i authenticate in an AWS UBUNTU instance to pull Google Analytics metrics?? Is there any other way??

I copied oauth_token and .httr-oauth files from my local machine to AWS instance, commented out lines 4,5 and that's it. I am able to pull the Google Analytics metrics.