我需要使用访问 token 对 Google Drive 进行身份验证,而无需重定向到网络浏览器。我尝试使用下面的代码进行身份验证
drive_auth(token = new_access_token_drive, use_oob = TRUE)
其中 new_access_token_drive
是 Bearer xxxx.xxxxx-xxxx
形式的访问 token
但是当我尝试使用上述代码进行身份验证时,它会重定向到网络浏览器
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.
如何使用 R 进行身份验证而不重定向到浏览器?
最佳答案
问题是您需要了解 Oauth2 的工作原理。 Oauth2 允许开发人员请求用户同意访问其数据。为了同意访问,授权服务器上的网页会向用户显示,没有办法解决这个问题。
How can I authenticate without being redirected to the browser using R?
如果用户没有通过网络浏览器授权您的应用程序,您就无法对用户帐户进行身份验证。
但是,如果这是您自己的个人帐户,您正尝试访问,并且您只能访问该帐户。那么你应该考虑查看service accounts .
关于R:如何使用基于网络的平台的访问 token 来验证谷歌驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62530158/