@TriKrista

Как получить список файлов из Google Drive?

Пытаюсь поличить список таким вот образом:
GoogleDrive::GoogleDrive(QObject *parent) : QObject(parent) {
    auth = new QOAuth2AuthorizationCodeFlow;
    auth->setScope("email");

    connect(auth, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::openUrl);

    connect(auth, &QOAuth2AuthorizationCodeFlow::statusChanged, [=](QAbstractOAuth::Status status) {
            if (status == QAbstractOAuth::Status::Granted) {
                emit authenticated();
            }
        });

    connect(this, &GoogleDrive::authenticated, this, &GoogleDrive::sendRequest);

    QString val;
    QFile file;
    file.setFileName("/path/client.json");
    file.open(QIODevice::ReadOnly | QIODevice::Text);
    val = file.readAll();
    file.close();

    QJsonDocument document = QJsonDocument::fromJson(val.toUtf8());
    const auto object = document.object();
    const auto settingsObject = object["installed"].toObject();
    const QUrl authUri(settingsObject["auth_uri"].toString());
    const auto clientId = settingsObject["client_id"].toString();
    const QUrl tokenUri(settingsObject["token_uri"].toString());
    const auto clientSecret(settingsObject["client_secret"].toString());
    const auto redirectUris = settingsObject["redirect_uris"].toArray();
    const QUrl redirectUri(redirectUris[0].toString());
    const auto port = static_cast<quint16>(redirectUri.port());

    auth->setAuthorizationUrl(authUri);
    auth->setClientIdentifier(clientId);
    auth->setAccessTokenUrl(tokenUri);
    auth->setClientIdentifierSharedKey(clientSecret);

    auto replyHandler = new QOAuthHttpServerReplyHandler(port);
    auth->setReplyHandler(replyHandler);
    auth->grant();
}

void GoogleDrive::sendRequest() {
    reply = auth->get(QUrl("https://www.googleapis.com/drive/v3/files"));
    connect(reply, &QNetworkReply::finished, this, &GoogleDrive::replyFinished);
    connect(reply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),
        [=](QNetworkReply::NetworkError error) {
            qDebug() << "error:" << error << " (" << reply->errorString() << ")";
        });
}

void GoogleDrive::replyFinished() {
    qDebug() << "answer:" << reply->readAll();
}


но вместо списка приходит данный ответ:

{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}

  • Вопрос задан
  • 521 просмотр
Пригласить эксперта
Ответы на вопрос 1
@rockstardavid
Go/PHP
Вы уперлись в лимиты, ответ внимательно читайте - Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы