Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. YouTube API v3 - upload video
Forum Updated to NodeBB v4.3 + New Features

YouTube API v3 - upload video

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yatongen
    wrote on last edited by
    #1

    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?

    I'm use gcc 4.7.2 and Qt 4.8.4 + QtCreator 2.6.1 from Windows 7

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      don't you use the same QNAM instance you use for authorization?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yatongen
        wrote on last edited by
        #3

        [quote author="raven-worx" date="1377076229"]don't you use the same QNAM instance you use for authorization?[/quote]

        No, I use two different instance QNAM. It's important to use the same?

        I'm use gcc 4.7.2 and Qt 4.8.4 + QtCreator 2.6.1 from Windows 7

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          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.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            yatongen
            wrote on last edited by
            #5

            I try, It's not work =(
            [quote author="raven-worx" date="1377078657"]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.[/quote]

            I'm use gcc 4.7.2 and Qt 4.8.4 + QtCreator 2.6.1 from Windows 7

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              same error?
              Does the RAW HTTP request look as it should?

              show some code please.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                yatongen
                wrote on last edited by
                #7

                How I can get it?

                @for(QByteArray arr : request.rawHeaderList()){
                qDebug() << arr;
                }@

                not work
                [quote author="raven-worx" date="1377079515"]same error?
                Does the RAW HTTP request look as it should?

                show some code please.
                [/quote]

                I'm use gcc 4.7.2 and Qt 4.8.4 + QtCreator 2.6.1 from Windows 7

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  TheFox
                  wrote on last edited by
                  #8

                  try connecting
                  @QNetworkAccessManager::authenticationRequired(QNetworkReply * reply, QAuthenticator * authenticator)@
                  to a custom slot to test if you need authentication.

                  1 Reply Last reply
                  0
                  • raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by
                    #9

                    [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.

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved