| 23 | const static QUrl baseUrl(QStringLiteral("https://api.github.com")); |
| 24 | |
| 25 | KIO::StoredTransferJob* createHttpAuthJob(const QString &httpHeader) |
| 26 | { |
| 27 | QUrl url = baseUrl; |
| 28 | url = url.adjusted(QUrl::StripTrailingSlash); |
| 29 | url.setPath(url.path() + QLatin1String("/authorizations")); |
| 30 | |
| 31 | // generate a unique token, see bug 372144 |
| 32 | const QString tokenName = QLatin1String("KDevelop Github Provider : ") |
| 33 | + QHostInfo::localHostName() + QLatin1String(" - ") |
| 34 | + QDateTime::currentDateTimeUtc().toString(); |
| 35 | const QByteArray data = QByteArrayLiteral("{ \"scopes\": [\"repo\"], \"note\": \"") + tokenName.toUtf8() + QByteArrayLiteral("\" }"); |
| 36 | |
| 37 | KIO::StoredTransferJob *job = KIO::storedHttpPost(data, url, KIO::HideProgressInfo); |
| 38 | job->setProperty("requestedTokenName", tokenName); |
| 39 | job->addMetaData(QStringLiteral("customHTTPHeader"), httpHeader); |
| 40 | |
| 41 | return job; |
| 42 | } |
| 43 | |
| 44 | Resource::Resource(QObject *parent, ProviderModel *model) |
| 45 | : QObject(parent), m_model(model) |
no test coverage detected