我想用我的Qt5程序在YouTube上加載myVideo.avi。我通過OAuth 2.0成功授權並獲得access_token而沒有錯誤。YouTube API v3 - 上傳視頻
但是,當我嘗試使用API https://developers.google.com/youtube/v3/docs/videos/insert 我得到了一些erros!
QString googleApiUrl = "https://www.googleapis.com/upload/youtube/v3/videos?access_token="+authorisation->getAccessToken()+"&part=snippet";
QNetworkRequest request;
request.setUrl(QUrl(googleApiUrl));
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::MixedType);
QHttpPart videoPart;
videoPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("video/*"));
videoPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("Slug"));
m_video = new QFile(m_filePath);
if (m_video->open(QIODevice::ReadOnly)) {
videoPart.setBodyDevice(m_video);
}
multiPart->append(videoPart);
m_networkManager = new QNetworkAccessManager();
m_networkManager->post(request,multiPart);
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(handleNetworkReply(QNetworkReply*)));
應答爲
"Host requires authentication"
"{
"error": {
"errors": [
{
"domain": "youtube.header",
"reason": "youtubeSignupRequired",
"message": "Unauthorized",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Unauthorized"
}
}
"
我做什麼了?
我怎麼沒看到你瀏覽OAuth2或將您的令牌應用到客戶端。 –