0

i face issues while connecting upload Picture to Google Drive . Sockect Time Out

my Intern was Good. This was my Code to upload receipt in Google Drive

This Sockect Time out Exeception Error

In have Increased time out session. For Connect the Google drive

 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
        }
    };
}

Google Drive ---->Connected--> Return Code

   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.second I was Getting "User Limit Exceed "

  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=************" } 

Increased quotes Limit in Google Developer Console . but still this Error.

Jaya Priya
  • 39
  • 1
  • 7

0 Answers0