   wf.exec (err) ->
 
 
+cmdPutSession = (options) ->
+  wf = wfall.create do ->
+    d =
+      itempath: if v = options.path then ':/' + v + ':' else ''
+    d
+  wf.push (hooks, callback) ->
+    readToken options, (err, auth) ->
+      hooks.auth = auth
+      callback()
+  wf.push (hooks, callback) -> # createUploadSession
+    p = hooks.itempath
+    par =
+      uri: [options.ROOT, options.user, options.dirve, '/root', encodeURIComponent(p), '/createUploadSession'].join ''
+      headers:
+        Authorization: 'bearer ' + hooks.auth.access_token
+        'Content-Type': mime.lookup options.localpath
+      method: 'POST'
+      json: yes
+    request par, (err, resp, body) ->
+      logger.debug body
+      hooks.session = body
+      callback()
+  wf.push (hooks, callback) ->
+    fs.readFile options.localpath, {encoding: null}, (err, data) ->
+      logger.error err if err
+      logger.debug 'file length', data.length
+      hooks.buffs = _.chunk data, 5 * 1024 * 1024
+      callback()
+  wf.push (hooks, callback) ->
+    last = null
+    iter = (buf, fin) ->
+      par =
+        uri: hooks.session.uploadUrl
+        headers:
+          'Content-Range': hooks.session.nextExpectedRanges[0] + (buf.length - 1) + '/128'
+          'Content-Length': buf.length
+        method: 'PUT'
+        body: Buffer.from buf
+      logger.trace '%j', _.omit par, 'body'
+      request par, (err, resp, body) ->
+        logger.error err if err
+        logger.debug body if body.error
+        logger.debug body
+    async.eachLimit hooks.buffs, 1, iter
+
+  wf.exec (err) ->
+
+
 defaultOptions =
   ROOT: 'https://graph.microsoft.com'
   user: '/v1.0/me'
   dirve: '/drive'
   authinfo: '.odAuthInfo'
+  scope: 'offline_access files.readwrite.all'
+  redirect_uri: 'http://localhost'
+
 
 main = () ->
   program.version '1.0.0'


cmdAuth = (options) ->
  wf = wfall.create
    open: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=#{client_id}&scope=#{encodeURIComponent scope}&response_type=code&redirect_uri=#{encodeURIComponent redirect_uri}"
  wf.push (hooks, callback) ->
    console.log "OPEN", hooks.open
    getInput (err, code) ->
      hooks.code = code
      callback()
  wf.push (hooks, callback) ->
    getToken hooks.code, (err, auth) ->
      hooks.auth = auth
      callback()
  wf.push (hooks, callback) ->
    console.log hooks.auth



cmdPut = (options) ->
  wf = wfall.create
    stream: fs.createReadStream options.localpath
  wf.push (hooks, callback) ->
