Android studio 我在使用GoogleDriveAPI时面临两个问题:套接字超时异常和用户限制超出
我在将上传图片连接到Google Drive时遇到问题。socket超时 我的实习生很好。 实际上,我们增加了会话的超时时间。用于连接谷歌硬盘Android studio 我在使用GoogleDriveAPI时面临两个问题:套接字超时异常和用户限制超出,android-studio,google-drive-api,Android Studio,Google Drive Api,我在将上传图片连接到Google Drive时遇到问题。socket超时 我的实习生很好。 实际上,我们增加了会话的超时时间。用于连接谷歌硬盘 private HttpRequestInitializer setHttpTimeout(final HttpRequestInitializer requestInitializer) { return new HttpRequestInitializer() { @Override public voi
private HttpRequestInitializer setHttpTimeout(final HttpRequestInitializer requestInitializer) {
return new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest httpRequest) throws IOException {
requestInitializer.initialize(httpRequest);
httpRequest.setConnectTimeout(4 * 60000); // 3 minutes connect timeout
httpRequest.setReadTimeout(3 * 60000); // 3 minutes read timeout
}
};
}
谷歌硬盘-->已连接-->返回代码
private void handleSignInResult(Intent result) {
GoogleSignIn.getSignedInAccountFromIntent(result)
.addOnSuccessListener(googleAccount -> {
Log.d(TAG, "Signed in as " + googleAccount.getEmail());
// Use the authenticated account to sign in to the Drive service.
SharedPreferences.Editor edit = settings.edit();
edit.putString("GoogleDriveID", "" + googleAccount.getEmail());
edit.commit();
googleSignInAccount=googleAccount;
accountName=googleAccount.getEmail();
GoogleAccountCredential credential =
GoogleAccountCredential.usingOAuth2(
this, Collections.singleton(DriveScopes.DRIVE_FILE));
credential.setSelectedAccount(googleAccount.getAccount());
Drive googleDriveService = new Drive.Builder( AndroidHttp.newCompatibleTransport(),
new GsonFactory(), setHttpTimeout(credential)).setApplicationName("nnnnn")
.build();
service=googleDriveService;
2.第二,我得到了“超出用户限制”
增加了谷歌开发者控制台的报价限制。但仍然存在此错误。错误消息说您的报价超出了范围。你能核实一下吗?是的,报价限制为100,你打了多少个电话?每个用户50个电话可能重复
ERR-00006-Google Drive upload|StackTrace: GLOBAL::saveFileToDrive::IOException
com.google.api.client.googleapis.json.GoogleJsonResponseException:
403 Forbidden { "code": 403, "errors": [ { "domain": "usageLimits", "message": "User Rate
Limit Exceeded.
Rate of requests for user exceed configured project quota.
You may consider re-evaluating expected per-user traffic to the API and adjust project
quota limits accordingly.
You may monitor aggregate quota usage and adjust limits in the
API Console: https://console.developers.google.com/apis/api/drive.googleapis.com/quotas?
project=344828444511",
"reason": "userRateLimitExceeded", "extendedHelp":
"https://console.developers.google.com/apis/api/drive.googleapis.com/quotas?
project=************" } ],
"message": "User Rate Limit Exceeded. Rate of requests for user exceed configured project
quota.
You may consider re-evaluating expected per-user traffic to the API and adjust project
quota limits accordingly.
You may monitor aggregate quota usage and adjust limits in the API Console:
https://console.developers.google.com/apis/api/drive.googleapis.com/quotas?
project=************" }