Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法生成应用access-token #19

Open
banpie opened this issue Dec 2, 2019 · 1 comment
Open

无法生成应用access-token #19

banpie opened this issue Dec 2, 2019 · 1 comment

Comments

@banpie
Copy link

banpie commented Dec 2, 2019

你好,根据文档的指南,我:

  1. 在Mac配置好了node和npm的环境;
  2. 在mac中创建了一个文件夹,文档结构如下:

image

  1. 编辑tb.js的代码如下:
const { TWS } = require('tws-auth')

const tws = new TWS({
  appId: '这里我填写应用ID',
  appSecrets: ['里我填写应用密钥', '这里我填写跟前面一样的应用密钥'],
  host: 'https://auth.teambitionapis.com'
})

;(async function () {
  console.log(await tws.request('GET', '/version'))
  console.log(await tws.get('/version'))
  console.log(await tws.authSrv.getUserById('59291f0178af6230601abecc'))
  console.log(await tws
    .withTenant('5c3d3615984f1e0001bca174', 'organization')
    .get('/v1/projects/5de3b5dbb9d85d0018d378df')
  )
})()

备注:;(async function () 后面涉及到organization和project的部分,我填写了组织的id和随便一个项目的ID。

  1. 在terminal中运行进入上述文件夹,然后运行node tb.js ,然后提示如下:
IncomingMessage {
  _readableState: ReadableState {
    objectMode: false,
    highWaterMark: 16384,
    buffer: BufferList { head: null, tail: null, length: 0 },
    length: 0,
    pipes: null,
    pipesCount: 0,
    flowing: true,
    ended: true,
    endEmitted: true,
    reading: false,
    sync: true,
    needReadable: false,
    emittedReadable: false,
    readableListening: false,
    resumeScheduled: false,
    paused: false,
    emitClose: true,
    autoDestroy: false,
    destroyed: false,
    defaultEncoding: 'utf8',
    awaitDrain: 0,
    readingMore: true,
    decoder: null,
    encoding: null
  },
  readable: false,
  _events: [Object: null prototype] {
    end: [ [Function: responseOnEnd], [Function] ],
    close: [ [Function], [Function] ],
    data: [Function],
    error: [Function]
  },
  _eventsCount: 4,
  _maxListeners: undefined,
  socket: TLSSocket {
    _tlsOptions: {
      allowHalfOpen: undefined,
      pipe: false,
      secureContext: [SecureContext],
      isServer: false,
      requestCert: true,
      rejectUnauthorized: false,
      session: undefined,
      ALPNProtocols: undefined,
      requestOCSP: undefined,
      enableTrace: undefined
    },
    _secureEstablished: true,
    _securePending: false,
    _newSessionPending: false,
    _controlReleased: true,
    _SNICallback: null,
    servername: 'auth.teambitionapis.com',
    alpnProtocol: false,
    authorized: false,
    authorizationError: 'ERR_TLS_CERT_ALTNAME_INVALID',
    encrypted: true,
    _events: [Object: null prototype] {
      close: [Array],
      end: [Function: onReadableStreamEnd],
      newListener: [Function: keylogNewListener],
      secure: [Function: onConnectSecure],
      session: [Function],
      free: [Function: onFree],
      agentRemove: [Function: onRemove],
      error: [Function]
    },
    _eventsCount: 8,
    connecting: false,
    _hadError: false,
    _parent: null,
    _host: 'auth.teambitionapis.com',
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: null,
      pipesCount: 0,
      flowing: true,
      ended: false,
      endEmitted: false,
      reading: true,
      sync: false,
      needReadable: true,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      paused: false,
      emitClose: false,
      autoDestroy: false,
      destroyed: false,
      defaultEncoding: 'utf8',
      awaitDrain: 0,
      readingMore: false,
      decoder: null,
      encoding: null
    },
    readable: true,
    _maxListeners: undefined,
    _writableState: WritableState {
      objectMode: false,
      highWaterMark: 16384,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: false,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: false,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      bufferedRequest: null,
      lastBufferedRequest: null,
      pendingcb: 0,
      prefinished: false,
      errorEmitted: false,
      emitClose: false,
      autoDestroy: false,
      bufferedRequestCount: 0,
      corkedRequestsFree: [Object]
    },
    writable: true,
    allowHalfOpen: false,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: undefined,
    _server: null,
    ssl: TLSWrap {
      _parent: [TCP],
      _parentWrap: undefined,
      _secureContext: [SecureContext],
      reading: true,
      onhandshakestart: [Function: noop],
      onhandshakedone: [Function],
      onocspresponse: [Function: onocspresponse],
      onnewsession: [Function: onnewsessionclient],
      onkeylog: [Function: onkeylogclient],
      onerror: [Function: onerror],
      [Symbol(owner)]: [Circular]
    },
    _requestCert: true,
    _rejectUnauthorized: false,
    parser: null,
    _httpMessage: null,
    timeout: 0,
    [Symbol(res)]: TLSWrap {
      _parent: [TCP],
      _parentWrap: undefined,
      _secureContext: [SecureContext],
      reading: true,
      onhandshakestart: [Function: noop],
      onhandshakedone: [Function],
      onocspresponse: [Function: onocspresponse],
      onnewsession: [Function: onnewsessionclient],
      onkeylog: [Function: onkeylogclient],
      onerror: [Function: onerror],
      [Symbol(owner)]: [Circular]
    },
    [Symbol(asyncId)]: -1,
    [Symbol(kHandle)]: TLSWrap {
      _parent: [TCP],
      _parentWrap: undefined,
      _secureContext: [SecureContext],
      reading: true,
      onhandshakestart: [Function: noop],
      onhandshakedone: [Function],
      onocspresponse: [Function: onocspresponse],
      onnewsession: [Function: onnewsessionclient],
      onkeylog: [Function: onkeylogclient],
      onerror: [Function: onerror],
      [Symbol(owner)]: [Circular]
    },
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: Timeout {
      _idleTimeout: -1,
      _idlePrev: null,
      _idleNext: null,
      _idleStart: 554,
      _onTimeout: null,
      _timerArgs: undefined,
      _repeat: null,
      _destroyed: true,
      [Symbol(refed)]: null,
      [Symbol(asyncId)]: 14,
      [Symbol(triggerId)]: 12
    },
    [Symbol(kBuffer)]: null,
    [Symbol(kBufferCb)]: null,
    [Symbol(kBufferGen)]: null,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0,
    [Symbol(connect-options)]: {
      rejectUnauthorized: false,
      ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
      checkServerIdentity: [Function: checkServerIdentity],
      minDHSize: 1024,
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      forever: true,
      strictSSL: false,
      pool: [Object],
      retryDelay: 2000,
      maxAttempts: 3,
      method: 'GET',
      headers: [Object],
      followRedirect: false,
      callback: [Function],
      readable: true,
      writable: true,
      explicitMethod: true,
      _qs: [Querystring],
      _auth: [Auth],
      _oauth: [OAuth],
      _multipart: [Multipart],
      _redirect: [Redirect],
      _tunnel: [Tunnel],
      setHeader: [Function],
      hasHeader: [Function],
      getHeader: [Function],
      removeHeader: [Function],
      localAddress: undefined,
      dests: [],
      __isRequestRequest: true,
      _callback: [Function],
      uri: [Url],
      proxy: null,
      tunnel: true,
      setHost: true,
      originalCookieHeader: undefined,
      _disableCookies: true,
      _jar: undefined,
      port: 443,
      host: 'auth.teambitionapis.com',
      path: null,
      _json: true,
      httpModule: [Object],
      agentClass: [Function: Agent],
      agentOptions: [Object],
      agent: [Agent],
      _started: true,
      href: 'https://auth.teambitionapis.com/version',
      _defaultAgent: [Agent],
      keepAlive: true,
      servername: 'auth.teambitionapis.com',
      _agentKey: 'auth.teambitionapis.com:443::::::::false::::::::::',
      encoding: null
    }
  },
  connection: TLSSocket {
    _tlsOptions: {
      allowHalfOpen: undefined,
      pipe: false,
      secureContext: [SecureContext],
      isServer: false,
      requestCert: true,
      rejectUnauthorized: false,
      session: undefined,
      ALPNProtocols: undefined,
      requestOCSP: undefined,
      enableTrace: undefined
    },
    _secureEstablished: true,
    _securePending: false,
    _newSessionPending: false,
    _controlReleased: true,
    _SNICallback: null,
    servername: 'auth.teambitionapis.com',
    alpnProtocol: false,
    authorized: false,
    authorizationError: 'ERR_TLS_CERT_ALTNAME_INVALID',
    encrypted: true,
    _events: [Object: null prototype] {
      close: [Array],
      end: [Function: onReadableStreamEnd],
      newListener: [Function: keylogNewListener],
      secure: [Function: onConnectSecure],
      session: [Function],
      free: [Function: onFree],
      agentRemove: [Function: onRemove],
      error: [Function]
    },
    _eventsCount: 8,
    connecting: false,
    _hadError: false,
    _parent: null,
    _host: 'auth.teambitionapis.com',
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: null,
      pipesCount: 0,
      flowing: true,
      ended: false,
      endEmitted: false,
      reading: true,
      sync: false,
      needReadable: true,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      paused: false,
      emitClose: false,
      autoDestroy: false,
      destroyed: false,
      defaultEncoding: 'utf8',
      awaitDrain: 0,
      readingMore: false,
      decoder: null,
      encoding: null
    },
    readable: true,
    _maxListeners: undefined,
    _writableState: WritableState {
      objectMode: false,
      highWaterMark: 16384,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: false,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: false,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      bufferedRequest: null,
      lastBufferedRequest: null,
      pendingcb: 0,
      prefinished: false,
      errorEmitted: false,
      emitClose: false,
      autoDestroy: false,
      bufferedRequestCount: 0,
      corkedRequestsFree: [Object]
    },
    writable: true,
    allowHalfOpen: false,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: undefined,
    _server: null,
    ssl: TLSWrap {
      _parent: [TCP],
      _parentWrap: undefined,
      _secureContext: [SecureContext],
      reading: true,
      onhandshakestart: [Function: noop],
      onhandshakedone: [Function],
      onocspresponse: [Function: onocspresponse],
      onnewsession: [Function: onnewsessionclient],
      onkeylog: [Function: onkeylogclient],
      onerror: [Function: onerror],
      [Symbol(owner)]: [Circular]
    },
    _requestCert: true,
    _rejectUnauthorized: false,
    parser: null,
    _httpMessage: null,
    timeout: 0,
    [Symbol(res)]: TLSWrap {
      _parent: [TCP],
      _parentWrap: undefined,
      _secureContext: [SecureContext],
      reading: true,
      onhandshakestart: [Function: noop],
      onhandshakedone: [Function],
      onocspresponse: [Function: onocspresponse],
      onnewsession: [Function: onnewsessionclient],
      onkeylog: [Function: onkeylogclient],
      onerror: [Function: onerror],
      [Symbol(owner)]: [Circular]
    },
    [Symbol(asyncId)]: -1,
    [Symbol(kHandle)]: TLSWrap {
      _parent: [TCP],
      _parentWrap: undefined,
      _secureContext: [SecureContext],
      reading: true,
      onhandshakestart: [Function: noop],
      onhandshakedone: [Function],
      onocspresponse: [Function: onocspresponse],
      onnewsession: [Function: onnewsessionclient],
      onkeylog: [Function: onkeylogclient],
      onerror: [Function: onerror],
      [Symbol(owner)]: [Circular]
    },
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: Timeout {
      _idleTimeout: -1,
      _idlePrev: null,
      _idleNext: null,
      _idleStart: 554,
      _onTimeout: null,
      _timerArgs: undefined,
      _repeat: null,
      _destroyed: true,
      [Symbol(refed)]: null,
      [Symbol(asyncId)]: 14,
      [Symbol(triggerId)]: 12
    },
    [Symbol(kBuffer)]: null,
    [Symbol(kBufferCb)]: null,
    [Symbol(kBufferGen)]: null,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0,
    [Symbol(connect-options)]: {
      rejectUnauthorized: false,
      ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
      checkServerIdentity: [Function: checkServerIdentity],
      minDHSize: 1024,
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      forever: true,
      strictSSL: false,
      pool: [Object],
      retryDelay: 2000,
      maxAttempts: 3,
      method: 'GET',
      headers: [Object],
      followRedirect: false,
      callback: [Function],
      readable: true,
      writable: true,
      explicitMethod: true,
      _qs: [Querystring],
      _auth: [Auth],
      _oauth: [OAuth],
      _multipart: [Multipart],
      _redirect: [Redirect],
      _tunnel: [Tunnel],
      setHeader: [Function],
      hasHeader: [Function],
      getHeader: [Function],
      removeHeader: [Function],
      localAddress: undefined,
      dests: [],
      __isRequestRequest: true,
      _callback: [Function],
      uri: [Url],
      proxy: null,
      tunnel: true,
      setHost: true,
      originalCookieHeader: undefined,
      _disableCookies: true,
      _jar: undefined,
      port: 443,
      host: 'auth.teambitionapis.com',
      path: null,
      _json: true,
      httpModule: [Object],
      agentClass: [Function: Agent],
      agentOptions: [Object],
      agent: [Agent],
      _started: true,
      href: 'https://auth.teambitionapis.com/version',
      _defaultAgent: [Agent],
      keepAlive: true,
      servername: 'auth.teambitionapis.com',
      _agentKey: 'auth.teambitionapis.com:443::::::::false::::::::::',
      encoding: null
    }
  },
  httpVersionMajor: 1,
  httpVersionMinor: 1,
  httpVersion: '1.1',
  complete: true,
  headers: {
    server: 'nginx',
    date: 'Mon, 02 Dec 2019 06:28:20 GMT',
    'content-type': 'application/json; charset=utf-8',
    'content-length': '175',
    connection: 'keep-alive',
    'keep-alive': 'timeout=60',
    vary: 'Accept-Encoding',
    'x-powered-by': 'Express',
    etag: 'W/"af-XgMHDQNYcsS29WHjPy7KksFTGZg"',
    teambition: 'v=release'
  },
  rawHeaders: [
    'Server',
    'nginx',
    'Date',
    'Mon, 02 Dec 2019 06:28:20 GMT',
    'Content-Type',
    'application/json; charset=utf-8',
    'Content-Length',
    '175',
    'Connection',
    'keep-alive',
    'Keep-Alive',
    'timeout=60',
    'Vary',
    'Accept-Encoding',
    'X-Powered-By',
    'Express',
    'ETag',
    'W/"af-XgMHDQNYcsS29WHjPy7KksFTGZg"',
    'Teambition',
    'v=release'
  ],
  trailers: {},
  rawTrailers: [],
  aborted: false,
  upgrade: false,
  url: '',
  method: null,
  statusCode: 200,
  statusMessage: 'OK',
  client: TLSSocket {
    _tlsOptions: {
      allowHalfOpen: undefined,
      pipe: false,
      secureContext: [SecureContext],
      isServer: false,
      requestCert: true,
      rejectUnauthorized: false,
      session: undefined,
      ALPNProtocols: undefined,
      requestOCSP: undefined,
      enableTrace: undefined
    },
    _secureEstablished: true,
    _securePending: false,
    _newSessionPending: false,
    _controlReleased: true,
    _SNICallback: null,
    servername: 'auth.teambitionapis.com',
    alpnProtocol: false,
    authorized: false,
    authorizationError: 'ERR_TLS_CERT_ALTNAME_INVALID',
    encrypted: true,
    _events: [Object: null prototype] {
      close: [Array],
      end: [Function: onReadableStreamEnd],
      newListener: [Function: keylogNewListener],
      secure: [Function: onConnectSecure],
      session: [Function],
      free: [Function: onFree],
      agentRemove: [Function: onRemove],
      error: [Function]
    },
    _eventsCount: 8,
    connecting: false,
    _hadError: false,
    _parent: null,
    _host: 'auth.teambitionapis.com',
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: null,
      pipesCount: 0,
      flowing: true,
      ended: false,
      endEmitted: false,
      reading: true,
      sync: false,
      needReadable: true,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      paused: false,
      emitClose: false,
      autoDestroy: false,
      destroyed: false,
      defaultEncoding: 'utf8',
      awaitDrain: 0,
      readingMore: false,
      decoder: null,
      encoding: null
    },
    readable: true,
    _maxListeners: undefined,
    _writableState: WritableState {
      objectMode: false,
      highWaterMark: 16384,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: false,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: false,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      bufferedRequest: null,
      lastBufferedRequest: null,
      pendingcb: 0,
      prefinished: false,
      errorEmitted: false,
      emitClose: false,
      autoDestroy: false,
      bufferedRequestCount: 0,
      corkedRequestsFree: [Object]
    },
    writable: true,
    allowHalfOpen: false,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: undefined,
    _server: null,
    ssl: TLSWrap {
      _parent: [TCP],
      _parentWrap: undefined,
      _secureContext: [SecureContext],
      reading: true,
      onhandshakestart: [Function: noop],
      onhandshakedone: [Function],
      onocspresponse: [Function: onocspresponse],
      onnewsession: [Function: onnewsessionclient],
      onkeylog: [Function: onkeylogclient],
      onerror: [Function: onerror],
      [Symbol(owner)]: [Circular]
    },
    _requestCert: true,
    _rejectUnauthorized: false,
    parser: null,
    _httpMessage: null,
    timeout: 0,
    [Symbol(res)]: TLSWrap {
      _parent: [TCP],
      _parentWrap: undefined,
      _secureContext: [SecureContext],
      reading: true,
      onhandshakestart: [Function: noop],
      onhandshakedone: [Function],
      onocspresponse: [Function: onocspresponse],
      onnewsession: [Function: onnewsessionclient],
      onkeylog: [Function: onkeylogclient],
      onerror: [Function: onerror],
      [Symbol(owner)]: [Circular]
    },
    [Symbol(asyncId)]: -1,
    [Symbol(kHandle)]: TLSWrap {
      _parent: [TCP],
      _parentWrap: undefined,
      _secureContext: [SecureContext],
      reading: true,
      onhandshakestart: [Function: noop],
      onhandshakedone: [Function],
      onocspresponse: [Function: onocspresponse],
      onnewsession: [Function: onnewsessionclient],
      onkeylog: [Function: onkeylogclient],
      onerror: [Function: onerror],
      [Symbol(owner)]: [Circular]
    },
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: Timeout {
      _idleTimeout: -1,
      _idlePrev: null,
      _idleNext: null,
      _idleStart: 554,
      _onTimeout: null,
      _timerArgs: undefined,
      _repeat: null,
      _destroyed: true,
      [Symbol(refed)]: null,
      [Symbol(asyncId)]: 14,
      [Symbol(triggerId)]: 12
    },
    [Symbol(kBuffer)]: null,
    [Symbol(kBufferCb)]: null,
    [Symbol(kBufferGen)]: null,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0,
    [Symbol(connect-options)]: {
      rejectUnauthorized: false,
      ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
      checkServerIdentity: [Function: checkServerIdentity],
      minDHSize: 1024,
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      forever: true,
      strictSSL: false,
      pool: [Object],
      retryDelay: 2000,
      maxAttempts: 3,
      method: 'GET',
      headers: [Object],
      followRedirect: false,
      callback: [Function],
      readable: true,
      writable: true,
      explicitMethod: true,
      _qs: [Querystring],
      _auth: [Auth],
      _oauth: [OAuth],
      _multipart: [Multipart],
      _redirect: [Redirect],
      _tunnel: [Tunnel],
      setHeader: [Function],
      hasHeader: [Function],
      getHeader: [Function],
      removeHeader: [Function],
      localAddress: undefined,
      dests: [],
      __isRequestRequest: true,
      _callback: [Function],
      uri: [Url],
      proxy: null,
      tunnel: true,
      setHost: true,
      originalCookieHeader: undefined,
      _disableCookies: true,
      _jar: undefined,
      port: 443,
      host: 'auth.teambitionapis.com',
      path: null,
      _json: true,
      httpModule: [Object],
      agentClass: [Function: Agent],
      agentOptions: [Object],
      agent: [Agent],
      _started: true,
      href: 'https://auth.teambitionapis.com/version',
      _defaultAgent: [Agent],
      keepAlive: true,
      servername: 'auth.teambitionapis.com',
      _agentKey: 'auth.teambitionapis.com:443::::::::false::::::::::',
      encoding: null
    }
  },
  _consuming: false,
  _dumped: false,
  req: ClientRequest {
    _events: [Object: null prototype] {
      socket: [Function],
      response: [Function: bound ],
      error: [Array],
      drain: [Function],
      timeout: [Function],
      prefinish: [Function: requestOnPrefinish]
    },
    _eventsCount: 6,
    _maxListeners: undefined,
    outputData: [],
    outputSize: 0,
    writable: true,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: true,
    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: 'auth.teambitionapis.com',
      alpnProtocol: false,
      authorized: false,
      authorizationError: 'ERR_TLS_CERT_ALTNAME_INVALID',
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 8,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'auth.teambitionapis.com',
      _readableState: [ReadableState],
      readable: true,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: true,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: false,
      parser: null,
      _httpMessage: null,
      timeout: 0,
      [Symbol(res)]: [TLSWrap],
      [Symbol(asyncId)]: -1,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: Timeout {
        _idleTimeout: -1,
        _idlePrev: null,
        _idleNext: null,
        _idleStart: 554,
        _onTimeout: null,
        _timerArgs: undefined,
        _repeat: null,
        _destroyed: true,
        [Symbol(refed)]: null,
        [Symbol(asyncId)]: 14,
        [Symbol(triggerId)]: 12
      },
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    connection: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      _SNICallback: null,
      servername: 'auth.teambitionapis.com',
      alpnProtocol: false,
      authorized: false,
      authorizationError: 'ERR_TLS_CERT_ALTNAME_INVALID',
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 8,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'auth.teambitionapis.com',
      _readableState: [ReadableState],
      readable: true,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: true,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: false,
      parser: null,
      _httpMessage: null,
      timeout: 0,
      [Symbol(res)]: [TLSWrap],
      [Symbol(asyncId)]: -1,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: Timeout {
        _idleTimeout: -1,
        _idlePrev: null,
        _idleNext: null,
        _idleStart: 554,
        _onTimeout: null,
        _timerArgs: undefined,
        _repeat: null,
        _destroyed: true,
        [Symbol(refed)]: null,
        [Symbol(asyncId)]: 14,
        [Symbol(triggerId)]: 12
      },
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    _header: 'GET /version HTTP/1.1\r\n' +
      'User-Agent: tws-auth/3.2.6 (Darwin; 19.0.0) Node.js/v12.13.1 test/1.0.0\r\n' +
      'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NzUyNjY0MDAsImV4cCI6MTU3NTI3MDM2MCwiX2FwcElkIjoiNzhmOTVlOTJjMDZhNTQ2ZjdkYWI3MzI3In0.IgtFhceKZPAGy2aW68TOHGMccD7QrnSWmpxdvRfIC0Q\r\n' +
      'host: auth.teambitionapis.com\r\n' +
      'accept: application/json\r\n' +
      'Connection: keep-alive\r\n' +
      '\r\n',
    _onPendingData: [Function: noopPendingOutput],
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object],
      requests: {},
      sockets: {},
      freeSockets: [Object],
      keepAliveMsecs: 1000,
      keepAlive: true,
      maxSockets: 100,
      maxFreeSockets: 256,
      maxCachedSessions: 100,
      _sessionCache: [Object]
    },
    socketPath: undefined,
    method: 'GET',
    path: '/version',
    _ended: true,
    res: [Circular],
    aborted: false,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    [Symbol(kNeedDrain)]: false,
    [Symbol(isCorked)]: false,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      'user-agent': [Array],
      authorization: [Array],
      host: [Array],
      accept: [Array]
    }
  },
  request: Request {
    _events: [Object: null prototype] {
      error: [Function: bound ],
      complete: [Function: bound ],
      pipe: [Function],
      data: [Function],
      end: [Function]
    },
    _eventsCount: 5,
    _maxListeners: undefined,
    forever: true,
    strictSSL: false,
    timeout: 3000,
    pool: { maxSockets: 100, 'https:false': [Agent] },
    retryDelay: 2000,
    maxAttempts: 3,
    method: 'GET',
    headers: {
      'User-Agent': 'tws-auth/3.2.6 (Darwin; 19.0.0) Node.js/v12.13.1 test/1.0.0',
      Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NzUyNjY0MDAsImV4cCI6MTU3NTI3MDM2MCwiX2FwcElkIjoiNzhmOTVlOTJjMDZhNTQ2ZjdkYWI3MzI3In0.IgtFhceKZPAGy2aW68TOHGMccD7QrnSWmpxdvRfIC0Q',
      accept: 'application/json'
    },
    followRedirect: false,
    callback: [Function],
    readable: true,
    writable: true,
    explicitMethod: true,
    _qs: Querystring {
      request: [Circular],
      lib: [Object],
      useQuerystring: undefined,
      parseOptions: {},
      stringifyOptions: {}
    },
    _auth: Auth {
      request: [Circular],
      hasAuth: false,
      sentAuth: false,
      bearerToken: null,
      user: null,
      pass: null
    },
    _oauth: OAuth { request: [Circular], params: null },
    _multipart: Multipart {
      request: [Circular],
      boundary: '30a59bd9-b511-42a8-a2f5-489bc41734ec',
      chunked: false,
      body: null
    },
    _redirect: Redirect {
      request: [Circular],
      followRedirect: true,
      followRedirects: false,
      followAllRedirects: false,
      followOriginalHttpMethod: false,
      allowRedirect: [Function],
      maxRedirects: 10,
      redirects: [],
      redirectsFollowed: 0,
      removeRefererHeader: false
    },
    _tunnel: Tunnel {
      request: [Circular],
      proxyHeaderWhiteList: [Array],
      proxyHeaderExclusiveList: []
    },
    setHeader: [Function],
    hasHeader: [Function],
    getHeader: [Function],
    removeHeader: [Function],
    localAddress: undefined,
    dests: [],
    __isRequestRequest: true,
    _callback: [Function],
    uri: Url {
      protocol: 'https:',
      slashes: true,
      auth: null,
      host: 'auth.teambitionapis.com',
      port: 443,
      hostname: 'auth.teambitionapis.com',
      hash: null,
      search: null,
      query: null,
      pathname: '/version',
      path: '/version',
      href: 'https://auth.teambitionapis.com/version'
    },
    rejectUnauthorized: false,
    proxy: null,
    tunnel: true,
    setHost: true,
    originalCookieHeader: undefined,
    _disableCookies: true,
    _jar: undefined,
    port: 443,
    host: 'auth.teambitionapis.com',
    path: '/version',
    _json: true,
    httpModule: {
      Agent: [Function: Agent],
      globalAgent: [Agent],
      Server: [Function: Server],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request]
    },
    agentClass: [Function: Agent],
    agentOptions: { keepAlive: true },
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object],
      requests: {},
      sockets: {},
      freeSockets: [Object],
      keepAliveMsecs: 1000,
      keepAlive: true,
      maxSockets: 100,
      maxFreeSockets: 256,
      maxCachedSessions: 100,
      _sessionCache: [Object]
    },
    _started: true,
    href: 'https://auth.teambitionapis.com/version',
    req: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 6,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      socket: [TLSSocket],
      connection: [TLSSocket],
      _header: 'GET /version HTTP/1.1\r\n' +
        'User-Agent: tws-auth/3.2.6 (Darwin; 19.0.0) Node.js/v12.13.1 test/1.0.0\r\n' +
        'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NzUyNjY0MDAsImV4cCI6MTU3NTI3MDM2MCwiX2FwcElkIjoiNzhmOTVlOTJjMDZhNTQ2ZjdkYWI3MzI3In0.IgtFhceKZPAGy2aW68TOHGMccD7QrnSWmpxdvRfIC0Q\r\n' +
        'host: auth.teambitionapis.com\r\n' +
        'accept: application/json\r\n' +
        'Connection: keep-alive\r\n' +
        '\r\n',
      _onPendingData: [Function: noopPendingOutput],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      path: '/version',
      _ended: true,
      res: [Circular],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      [Symbol(kNeedDrain)]: false,
      [Symbol(isCorked)]: false,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    },
    ntick: true,
    timeoutTimer: null,
    response: [Circular],
    originalHost: 'auth.teambitionapis.com',
    originalHostHeaderName: 'host',
    responseContent: [Circular],
    _destdata: true,
    _ended: true,
    _callbackCalled: true
  },
  toJSON: [Function: responseToJSON],
  caseless: Caseless {
    dict: {
      server: 'nginx',
      date: 'Mon, 02 Dec 2019 06:28:20 GMT',
      'content-type': 'application/json; charset=utf-8',
      'content-length': '175',
      connection: 'keep-alive',
      'keep-alive': 'timeout=60',
      vary: 'Accept-Encoding',
      'x-powered-by': 'Express',
      etag: 'W/"af-XgMHDQNYcsS29WHjPy7KksFTGZg"',
      teambition: 'v=release'
    }
  },
  body: {
    name: 'account-id',
    version: '0.2.0',
    startTime: '2019-12-02T06:28:20.791Z',
    buildTime: '2019-11-27T14:57:18+08:00',
    buildCommit: '7ca0fd8a78fcccf29b0b1bd205427b91c6023200'
  },
  attempts: 1,
  originalUrl: 'https://auth.teambitionapis.com/version',
  originalMethod: 'GET'
}
{
  name: 'account-id',
  version: '0.2.0',
  startTime: '2019-12-02T06:28:20.848Z',
  buildTime: '2019-11-27T14:57:18+08:00',
  buildCommit: '7ca0fd8a78fcccf29b0b1bd205427b91c6023200'
}
http-errors deprecated non-error status code; use only 4xx or 5xx status codes node_modules/tws-auth/build/client.js:351:38
(node:19916) UnhandledPromiseRejectionWarning: Error: <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>进入企业</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="renderer" content="webkit">
    <meta name="robots" content="NOINDEX,NOFOLLOW">
    <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta http-equiv="x-dns-prefetch-control" content="on">
    <link rel="dns-prefetch" href="//g.alicdn.com" />
    <link rel="dns-prefetch" href="//img.alicdn.com" />
    <link rel="dns-prefetch" href="//gw.alicdn.com" />
    <link rel="dns-prefetch" href="//f.alicdn.com" />
    <link rel="apple-touch-icon" href="/web-statics/[email protected]" />
    <link rel="stylesheet" href="https://g.alicdn.com/aisc/at/0.1.26/teambition.min.css" />
    <link rel="stylesheet" href="https://g.alicdn.com/teambition-devcenter/account-id-assets/0.2.0/main.css"/>
  </head>
  <body>
    <div id="root"></div>
    <script>
      // apis
      window.API_URL = "https://www.teambition.com"
      window.AUTH_API_URL = "https://auth_services.teambition.com"
      window.ACCOUNT_API_URL = "https://account.teambition.com"
      window.APP_API_URL = "https://appshell.teambition.com"
      window.CMS_API_URL = ""
      // basic
      window.DEFAULT_APPID = "5cc034f2515f500001f06794"
      window.OPEN_PLATFORM_ID = "5d4cec30a55c09000171cbd4"
      window.APPLY_CODE = "false"
      window.NOAUTH_REDIRECT_URL = "https://account.teambition.com/login"
      window.APP_STORE_URL = "https://apps.teambition.com/element/:appId?organizationId=:orgId"
      window.IS_PRIVATE = "false"
    </script>
    <script src="//f.alicdn.com/babel-polyfill/6.16.0/polyfill.min.js"></script>
    <script src="https://g.alicdn.com/code/lib/react/16.8.6/umd/react.production.min.js"></script>
    <script src="https://g.alicdn.com/code/lib/react-dom/16.8.6/umd/react-dom.production.min.js"></script>
    <script src="https://g.alicdn.com/code/lib/redux/4.0.1/redux.min.js"></script>
    <script src="https://g.alicdn.com/code/lib/react-redux/7.1.0-rc.1/react-redux.min.js"></script>
    <script src="https://g.alicdn.com/code/lib/redux-thunk/2.3.0/redux-thunk.min.js"></script>

    <script src="https://g.alicdn.com/aisc/at/0.1.26/at.min.js"></script>

    <script>
      window.cdnPath = "";
    </script>
    <script src="https://g.alicdn.com/teambition-devcenter/account-id-assets/0.2.0/main.js"></script>

  </body>
</html>

    at assertRes (/Users/halpfie/Desktop/test/node_modules/tws-auth/build/client.js:351:38)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async /Users/halpfie/Desktop/test/no.js:12:15
(node:19916) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19916) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

问题是:哪里可以看到accesstoken呢?或者我的步骤是否哪里有错误呢?

感谢!

@tolerious
Copy link

采用如下代码即可、

 var client = new Client({
    appId: teambitionConfig.appId,
    appSecrets: [teambitionConfig.appSecrets],
    host: "https://open.teambition.com/api",
  });
  console.log(client.signAppToken());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants