R: How to authenticate google drive using access Token from web-based platform

Viewed 395

I need to authenticate google drive using the access token without being redirected to the web browser. I tried to authenticate using the code below

drive_auth(token = new_access_token_drive, use_oob = TRUE)

where new_access_token_drive is the access token in the form Bearer xxxx.xxxxx-xxxx

But when I try to authenticate using the above code, it's redirecting to the web browser

The googledrive package is requesting access to your Google account. Select a pre-authorised account or enter '0' to obtain a new token. Press Esc/Ctrl + C to abort.

How can I authenticate without being redirected to the browser using R?

1 Answers

The thing is you need to understand how Oauth2 works. Oauth2 allows developers to request of a user consent to access their data. In order to consent to the access a web page on the authorization server is shown to the user there is no way around that.

How can I authenticate without being redirected to the browser using R?

You can not authenticate to a users account without them authorizing your application though the web browser.

If however this is your own personal account you are trying to access and you are only going to be access that account. Then you should consider looking into service accounts.

Related