[英]How can I force an android app to use only a certain account to use google drive api (GDAA)?
I am developing an android app that generates files and I need to upload these files to google drive but using only an specific account. 我正在开发一个可生成文件的android应用,我需要将这些文件上传到Google驱动器,但仅使用一个特定帐户。 Is there a way to do this?
有没有办法做到这一点?
For now I have this code that allows me to choose the account : 现在,我有了这段代码,可以选择该帐户:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
// Unable to resolve, message user appropriately
}
} else {
GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
}
}
Thanks in advance 提前致谢
No. The GoogleApiClient uses the google accounts present on the device to connect and thus the Drive Android API will only be able to fetch/create files on those account. 不能。GoogleApiClient使用设备上存在的Google帐户进行连接,因此Drive Android API将只能在这些帐户上获取/创建文件。 By definition if you want all the clients to backup to a single Drive account, all those client should have the credentials for that account which is not safe.
根据定义,如果您希望所有客户端都备份到单个Drive帐户,则所有这些客户端都应具有该帐户的凭据,这是不安全的。
It sounds like you need a single server endpoint where your clients can connect to and post any data. 听起来您需要一个客户端可以连接到并发布任何数据的服务器端点。 Look into storage APIs provided by firebase ( https://firebase.google.com/docs/storage/ ) if you want a pre-cooked solution.
如果您需要预先准备好的解决方案, 请查看firebase( https://firebase.google.com/docs/storage/ )提供的存储API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.