Je recommande de lire ce post qui m'a aidé à configurer et à se connecter à Google Drive avec Android
EDIT:
J'ai eu le même 500 serveur d'erreur, pour éviter cette erreur Google recommande le Exponential backoff
que selon eux:
Exponential backoff is a standard error handling strategy for network applications in which the client periodically retries a failed request over an increasing amount of time. If a high volume of requests or heavy network traffic causes the server to return errors, exponential backoff may be a good strategy for handling those errors. Conversely, it is not a relevant strategy for dealing with errors unrelated to rate-limiting, network volume or response times, such as invalid authorization credentials or file not found errors.
Used properly, exponential backoff increases the efficiency of bandwidth usage, reduces the number of requests required to get a successful response, and maximizes the throughput of requests in concurrent environments.
Exemple:
code Android:
FileList files = null;
for (int n = 0; n < 5; ++n) {
try {
setStatus("trying n = " + n);
files = service.files()
.list()
.setMaxResults(1)
.setQ("mimeType = 'application/vnd.google-apps.folder' and title = 'folder_title'")
.execute();
}
catch (GoogleJsonResponseException e)
{
if (e.getDetails().getCode() == 500) {
try {
Thread.sleep((1 << n) * 1000 + randomGenerator.nextInt(1001));
setStatus("sleep() n = " + n);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
setStatus("InterruptedException n = " + n + " " + e1.getMessage());
e1.printStackTrace();
}
}
}
}
J'ai testé ce code et dans le dernier essai, il se connecte avec succès
Google recommande d'utiliser le backoff Exponentielle avec 4xx et serveur 5xx error
Les 4xx server erreurs sont principalement pour le problème d'authentification