weixin_39877182
weixin_39877182
2020-12-05 03:35

Doesn't continue on first downloaded video

When I'm about to download the second video, there's a warning for the access token that it will be only available by the next 35 mins or so. Our session was 1 hour long and it stopped in the middle of my download and I think it has something to do with my expiring access token.


{ Error: Request failed with status code 4010011
    at createError (C:\Users\elaconico\desktop\destreamer\node_modules\axios\lib\core\createError.js:16:15)
    at settle (C:\Users\elaconico\desktop\destreamer\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (C:\Users\elaconico\desktop\destreamer\node_modules\axios\lib\adapters\http.js:236:11)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  config:
   { url: 'https://euno-1.api.microsoftstream.com/api/refreshtoken?api-version=1.4-private',
     method: 'get',
     headers:
      { Accept: 'application/json, text/plain, */*',
        Cookie: 'Authorization=uwu; path=/; SameSite=None; secure; httponly,Signature=9prqNGBZJQA8%252bKpXizhgR8PJcilOqjdn5KkYJMSaolU%253d; path=/; SameSite=None; secure; httponly',
        'User-Agent': 'axios/0.19.2' },
     transformRequest: [ [Function: transformRequest] ],
     transformResponse: [ [Function: transformResponse] ],
     timeout: 0,
     adapter: [Function: httpAdapter],
     xsrfCookieName: 'XSRF-TOKEN',
     xsrfHeaderName: 'X-XSRF-TOKEN',
     maxContentLength: -1,
     validateStatus: [Function: validateStatus],
     data: undefined },
  request:
   ClientRequest {
     domain: null,
     _events:
      { socket: [Function],
        abort: [Function],
        aborted: [Function],
        error: [Function],
        timeout: [Function],
        prefinish: [Function: requestOnPrefinish] },
     _eventsCount: 6,
     _maxListeners: undefined,
     output: [],
     outputEncodings: [],
     outputCallbacks: [],
     outputSize: 0,
     writable: true,
     _last: true,
     upgrading: false,
     chunkedEncoding: false,
     shouldKeepAlive: false,
     useChunkedEncodingByDefault: false,
     sendDate: false,
     _removedConnection: false,
     _removedContLen: false,
     _removedTE: false,
     _contentLength: 0,
     _hasBody: true,
     _trailer: '',
     finished: true,
     _headerSent: true,
     socket:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: 'euno-1.api.microsoftstream.com',
        npnProtocol: undefined,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'euno-1.api.microsoftstream.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 3337,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 34562,
        [Symbol(bytesRead)]: 353 },
     connection:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: 'euno-1.api.microsoftstream.com',
        npnProtocol: undefined,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'euno-1.api.microsoftstream.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 3337,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 34562,
        [Symbol(bytesRead)]: 353 },
     _header: 'GET /api/refreshtoken?api-version=1.4-private HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nCookie: Authorization=uwu; path=/; SameSite=None; secure; httponly,Signature=9prqNGBZJQA8%252bKpXizhgR8PJcilOqjdn5KkYJMSaolU%253d; path=/; SameSite=None; secure; httponly\r\nUser-Agent: axios/0.19.2\r\nHost: euno-1.api.microsoftstream.com\r\nConnection: close\r\n\r\n',
     _onPendingData: [Function: noopPendingOutput],
     agent:
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        maxCachedSessions: 100,
        _sessionCache: [Object] },
     socketPath: undefined,
     timeout: undefined,
     method: 'GET',
     path: '/api/refreshtoken?api-version=1.4-private',
     _ended: true,
     res:
      IncomingMessage {
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        socket: [Object],
        connection: [Object],
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        headers: [Object],
        rawHeaders: [Array],
        trailers: {},
        rawTrailers: [],
        upgrade: false,
        url: '',
        method: null,
        statusCode: 401,
        statusMessage: 'Unauthorized',
        client: [Object],
        _consuming: true,
        _dumped: false,
        req: [Circular],
        responseUrl: 'https://euno-1.api.microsoftstream.com/api/refreshtoken?api-version=1.4-private',
        redirects: [],
        read: [Function] },
     aborted: undefined,
     timeoutCb: null,
     upgradeOrConnect: false,
     parser: null,
     maxHeadersCount: null,
     _redirectable:
      Writable {
        _writableState: [Object],
        writable: true,
        domain: null,
        _events: [Object],
        _eventsCount: 2,
        _maxListeners: undefined,
        _options: [Object],
        _redirectCount: 0,
        _redirects: [],
        _requestBodyLength: 0,
        _requestBodyBuffers: [],
        _onNativeResponse: [Function],
        _currentRequest: [Circular],
        _currentUrl: 'https://euno-1.api.microsoftstream.com/api/refreshtoken?api-version=1.4-private' },
     [Symbol(outHeadersKey)]:
      { accept: [Array],
        cookie: [Array],
        'user-agent': [Array],
        host: [Array] } },
  response:
   { status: 401,
     statusText: 'Unauthorized',
     headers:
      { 'cache-control': 'no-cache',
        pragma: 'no-cache',
        expires: '-1',
        'x-ms-request-id': '40168b2c-37cd-47e9-97c4-ed1d3e394376',
        'access-control-expose-headers': 'x-ms-request-id',
        'www-authenticate': 'Bearer',
        'strict-transport-security': 'max-age=31536000; includeSubDomains',
        date: 'Sat, 16 May 2020 09:34:11 GMT',
        connection: 'close',
        'content-length': '0' },
     config:
      { url: 'https://euno-1.api.microsoftstream.com/api/refreshtoken?api-version=1.4-private',
        method: 'get',
        headers: [Object],
        transformRequest: [Array],
        transformResponse: [Array],
        timeout: 0,
        adapter: [Function: httpAdapter],
        xsrfCookieName: 'XSRF-TOKEN',
        xsrfHeaderName: 'X-XSRF-TOKEN',
        maxContentLength: -1,
        validateStatus: [Function: validateStatus],
        data: undefined },
     request:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 6,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: false,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _header: 'GET /api/refreshtoken?api-version=1.4-private HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nCookie: Authorization=uwu; path=/; SameSite=None; secure; httponly,Signature=9prqNGBZJQA8%252bKpXizhgR8PJcilOqjdn5KkYJMSaolU%253d; path=/; SameSite=None; secure; httponly\r\nUser-Agent: axios/0.19.2\r\nHost: euno-1.api.microsoftstream.com\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'GET',
        path: '/api/refreshtoken?api-version=1.4-private',
        _ended: true,
        res: [Object],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        _redirectable: [Object],
        [Symbol(outHeadersKey)]: [Object] },
     data: '' },
  isAxiosError: true,
  toJSON: [Function] }

Well it's not technically an issue but a good feature perhaps if we add it 😁 But all in all, this is a very at doing its job. [I hope I didn't post any private keys here]

该提问来源于开源项目:snobu/destreamer

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39784460 weixin_39784460 5月前

    This is still an unresolved problem, we have no good way to refresh the access token unless we hang on to a browser window.

    Doing OAuth won't work since people would have to consent to delegated permissions for destreamer, an action they may not have the rights for.

    You should remove the base64 cookie from your post (the long tower of garbled text). Most of it is opaque but still may pose a privacy risk.

    点赞 评论 复制链接分享
  • weixin_39588679 weixin_39588679 5月前

    I just had an idea, what if we relaunch an headless browser with the token before it expires, maybe that will give us a new session cookie with extended lifetime?

    点赞 评论 复制链接分享
  • weixin_39784460 weixin_39784460 5月前

    That should work, we would need a way to tell Chromium to store the IdP cookie and all the other session bits (localstorage/sessionstorage) so the next time we launch it headless it can pick those up.

    There seems to be no way to tell Chromium to hide its window, which i guess is a sane decision by the devs no matter how much it inconveniences us :)

    点赞 评论 复制链接分享
  • weixin_39588679 weixin_39588679 5月前

    See #155, it should solve this

    点赞 评论 复制链接分享

相关推荐