YouTube API v3 - upload video
-
I would like load myVideo.avi on YouTube with my Qt5 programm. I successful authorisation through OAuth 2.0 and get access_token without errors.
But when I try to use API "https://developers.google.com/youtube/v3/docs/videos/insert":https://developers.google.com/youtube/v3/docs/videos/insert
I get some 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*)));@
response-
@"Host requires authentication"
"{
"error": {
"errors": [
{
"domain": "youtube.header",
"reason": "youtubeSignupRequired",
"message": "Unauthorized",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Unauthorized"
}
}
" @
What I do wrong? -
don't you use the same QNAM instance you use for authorization?
-
maybe...it was just a guess of mine regarding the error message.
It may be that the authorization response sets some cookies which are missing for the following requests. -
-
same error?
Does the RAW HTTP request look as it should?show some code please.
-
[quote author="yatongen" date="1377080073"]How I can get it?
@for(QByteArray arr : request.rawHeaderList()){
qDebug() << arr;
}@not work
[/quote]
not only the raw headers. But use an application like "fiddler ":http://fiddler2.com to sniff out the HTTP-traffic.