gpt4 book ai didi

c++ - YouTube API v3 - 上传视频

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:11:02 25 4
gpt4 key购买 nike

我想用我的 Qt5 程序在 YouTube 上加载 myVideo.avi。我通过OAuth 2.0成功授权,并且没有错误地获得了access_token。

但是当我尝试使用 API 时 https://developers.google.com/youtube/v3/docs/videos/insert我有一些错误!

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"
}
}
"

我做错了什么?

最佳答案

youtubeSignupRequired 表示您正在通过 OAuth 2 流程并使用尚未关联 YouTube channel 的 Google 帐户授权访问。我建议再次检查流程并确认您正在使用正确的帐户授权访问。

顺便说一句,我建议提供 https://github.com/google/google-api-cpp-client一试。它是相当新的,与您自己进行原始 HTTP 调用相比,它可能会简化您的代码。

关于c++ - YouTube API v3 - 上传视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18352790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com