如何强制 android 应用仅使用特定帐户来使用 google 驱动器 api (GDAA)?

How can I force an android app to use only a certain account to use google drive api (GDAA)?

我正在开发一个生成文件的 android 应用程序,我需要将这些文件上传到 google 驱动器,但仅使用特定帐户。有办法吗?

现在我有这个代码可以让我选择帐户:

@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();
    }
}

提前致谢

没有。 GoogleApiClient 使用设备上存在的 google 帐户进行连接,因此云端硬盘 Android API 将只能 fetch/create 这些帐户上的文件。根据定义,如果您希望所有客户端都备份到单个 Drive 帐户,那么所有这些客户端都应该拥有该帐户的凭据,这是不安全的。

听起来您需要一个服务器端点,您的客户端可以在其中连接到 post 任何数据。如果您想要预煮解决方案,请查看 firebase (https://firebase.google.com/docs/storage/) 提供的存储 APIs。