 
 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}"
+    open: [
+      "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?"
+      "client_id=#{options.client_id}&"
+      "scope=#{encodeURIComponent options.scope}&"
+      "response_type=code&"
+      "redirect_uri=#{encodeURIComponent options.redirect_uri}"
+    ].join ''
   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
+    par = _.extend {}, {code: hooks.code}, _.pick options, ['client_id', 'client_secret', 'redirect_uri']
+    getToken par, (err, auth) ->
+      hooks.auth = _.extend auth,
+        createdAt: new Date()
+        client_id: options.client_id
+        client_secret: options.client_secret
       callback()
   wf.push (hooks, callback) ->
     console.log hooks.auth



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


  program.command 'auth'
    .description 'show auth uri && wait for {code} from stdin'
    .option '--client_id <value>'
    .option '--client_secret <value>'
    .option '-a --authinfo <filename>', 'save auth-info'
    .action (options) ->
      par = _.extend {}, defaultOptions, _.pick options, ['client_id', 'client_secret'].concat _.keys defaultOptions
      cmdAuth par

  program.command 'show <res>'
    .description 'show list/drive'
