Page 1 of 1

Oauth error - /oauth2/token api

Posted: Wed Nov 24, 2021 2:16 am
by rish
Hi,

We have a global client ID that is supposed to work with multiple builds , but it only works with one build now -

1) fixitfaster.simprosuite.com

It is supposed to work with following builds as well, but that is no longer the case -

2) enterprise-sandbox-au.simprosuite.com
3) glenco.simprosuite.com


Not sure what the issue is , it gives the error "Grant type not specified" but we have specified it as "authorisation_code" (as shown below)

Code: Select all

authTokenCode: function (baseUrl, client_id, client_secret, code, state, cb) {
    unirest
      .post(baseUrl + '/oauth2/token')
      .headers({
        Accept: 'application/json',
        'Content-Type': 'application/json',
      })
      .send({
        "grant_type": "authorization_code",
        "client_id": client_id,
        "client_secret": client_secret,
        "code": code,
        "state": state
      })
      .end(function (data) {
        console.log('THIS IS RESP',data);
        cb(data.body);
      })
  },
and our authTokenCode function clearly works with build 1, not sure why it does not work with build 2 and build 3.
All the settings are the same.
There are no changes in the "Applications" Tab of the client.



Following is the response from /oauth2/token api for build 2 and build 3.

Code: Select all


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,
  domain: null,
  _events:
   [Object: null prototype] {
     end:
      [ [Function: responseOnEnd], [Function], [Function], [Function] ],
     close: [ [Function], [Function] ],
     data: [Function],
     error: [Function] },
  _eventsCount: 4,
  _maxListeners: undefined,
  socket:
   TLSSocket {
     _tlsOptions:
      { pipe: false,
        secureContext: [SecureContext],
        isServer: false,
        requestCert: true,
        rejectUnauthorized: false,
        session: undefined,
        ALPNProtocols: undefined,
        requestOCSP: undefined },
     _secureEstablished: true,
     _securePending: false,
     _newSessionPending: false,
     _controlReleased: true,
     _SNICallback: null,
     servername: 'enterprise-sandbox-au.simprosuite.com',
     alpnProtocol: false,
     authorized: true,
     authorizationError: null,
     encrypted: true,
     _events:
      [Object: null prototype] {
        close: [Array],
        end: [Function: onReadableStreamEnd],
        newListener: [Function: keylogNewListener],
        secure: [Function: onConnectSecure],
        free: [Function: onFree],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener],
        finish: [Function] },
     _eventsCount: 9,
     connecting: false,
     _hadError: false,
     _handle:
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: true,
        onread: [Function: wrapper],
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onkeylog: [Function: onkeylogclient],
        onerror: [Function: onerror],
        [Symbol(owner)]: [Circular] },
     _parent: null,
     _host: 'enterprise-sandbox-au.simprosuite.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,
     domain: null,
     _maxListeners: undefined,
     _writableState:
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: true,
        needDrain: false,
        ending: true,
        ended: true,
        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: 1,
        prefinished: false,
        errorEmitted: false,
        emitClose: false,
        autoDestroy: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: false,
     allowHalfOpen: false,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: undefined,
     _server: null,
     ssl:
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: true,
        onread: [Function: wrapper],
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onkeylog: [Function: onkeylogclient],
        onerror: [Function: onerror],
        [Symbol(owner)]: [Circular] },
     _requestCert: true,
     _rejectUnauthorized: false,
     emit: [Function: wrapper],
     parser: null,
     _httpMessage:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Circular],
        connection: [Circular],
        _header:
         'POST /oauth2/token HTTP/1.1\r\nAccept: application/json\r\nreferer: http://enterprise-sandbox-au.simprosuite.com/oauth2/token\r\nhost: enterprise-sandbox-au.simprosuite.com\r\ncontent-length: 0\r\nx-newrelic-id: VgMFVVZVABACVFZSAgYOV1A=\r\nx-newrelic-transaction: PxQOV18CAQcIXVQABwFUXlQJFB8EBw8RVU4aWw4BVQsHXQBUU1EDAVwGD0NKQQ4EVl0HA1QIFTs=\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Agent],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        insecureHTTPParser: undefined,
        path: '/oauth2/token',
        _ended: true,
        res: [Circular],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        [Symbol(isCorked)]: false,
        [Symbol(outHeadersKey)]: [Object] },
     [Symbol(res)]:
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: true,
        onread: [Function: wrapper],
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onkeylog: [Function: onkeylogclient],
        onerror: [Function: onerror],
        [Symbol(owner)]: [Circular] },
     [Symbol(asyncId)]: 657637,
     [Symbol(lastWriteQueueSize)]: 0,
     [Symbol(timeout)]: null,
     [Symbol(kBytesRead)]: 0,
     [Symbol(kBytesWritten)]: 0,
     [Symbol(connect-options)]:
      { rejectUnauthorized: false,
        ciphers:
         '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,
        encoding: null,
        _agentKey:
         'enterprise-sandbox-au.simprosuite.com:443::::::::::::::::::',
        _started: true,
        agent: [Agent],
        originalHostHeaderName: 'host',
        originalHost: 'enterprise-sandbox-au.simprosuite.com',
        response: [IncomingMessage],
        ntick: true,
        href: 'https://enterprise-sandbox-au.simprosuite.com/oauth2/token',
        agentClass: [Function],
        httpModule: [Object],
        _json: true,
        path: null,
        host: 'enterprise-sandbox-au.simprosuite.com',
        port: 443,
        _jar: undefined,
        _disableCookies: true,
        originalCookieHeader: undefined,
        setHost: true,
        tunnel: true,
        proxy: null,
        uri: [Url],
        _callback: [Function: handleRequestResponse],
        __isRequestRequest: true,
        dests: [],
        pool: {},
        localAddress: undefined,
        removeHeader: [Function],
        getHeader: [Function],
        hasHeader: [Function],
        setHeader: [Function],
        _tunnel: [Tunnel],
        _redirect: [Redirect],
        _multipart: [Multipart],
        _oauth: [OAuth],
        _auth: [Auth],
        _qs: [Querystring],
        explicitMethod: true,
        writable: true,
        readable: true,
        callback: [Function],
        headers: [Object],
        method: 'post',
        _maxListeners: undefined,
        _eventsCount: 4,
        _events: [Object],
        domain: null,
        _defaultAgent: [Agent],
        servername: 'enterprise-sandbox-au.simprosuite.com',
        singleUse: true } },
  connection:
   TLSSocket {
     _tlsOptions:
      { pipe: false,
        secureContext: [SecureContext],
        isServer: false,
        requestCert: true,
        rejectUnauthorized: false,
        session: undefined,
        ALPNProtocols: undefined,
        requestOCSP: undefined },
     _secureEstablished: true,
     _securePending: false,
     _newSessionPending: false,
     _controlReleased: true,
     _SNICallback: null,
     servername: 'enterprise-sandbox-au.simprosuite.com',
     alpnProtocol: false,
     authorized: true,
     authorizationError: null,
     encrypted: true,
     _events:
      [Object: null prototype] {
        close: [Array],
        end: [Function: onReadableStreamEnd],
        newListener: [Function: keylogNewListener],
        secure: [Function: onConnectSecure],
        free: [Function: onFree],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener],
        finish: [Function] },
     _eventsCount: 9,
     connecting: false,
     _hadError: false,
     _handle:
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: true,
        onread: [Function: wrapper],
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onkeylog: [Function: onkeylogclient],
        onerror: [Function: onerror],
        [Symbol(owner)]: [Circular] },
     _parent: null,
     _host: 'enterprise-sandbox-au.simprosuite.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,
     domain: null,
     _maxListeners: undefined,
     _writableState:
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: true,
        needDrain: false,
        ending: true,
        ended: true,
        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: 1,
        prefinished: false,
        errorEmitted: false,
        emitClose: false,
        autoDestroy: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: false,
     allowHalfOpen: false,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: undefined,
     _server: null,
     ssl:
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: true,
        onread: [Function: wrapper],
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onkeylog: [Function: onkeylogclient],
        onerror: [Function: onerror],
        [Symbol(owner)]: [Circular] },
     _requestCert: true,
     _rejectUnauthorized: false,
     emit: [Function: wrapper],
     parser: null,
     _httpMessage:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Circular],
        connection: [Circular],
        _header:
         'POST /oauth2/token HTTP/1.1\r\nAccept: application/json\r\nreferer: http://enterprise-sandbox-au.simprosuite.com/oauth2/token\r\nhost: enterprise-sandbox-au.simprosuite.com\r\ncontent-length: 0\r\nx-newrelic-id: VgMFVVZVABACVFZSAgYOV1A=\r\nx-newrelic-transaction: PxQOV18CAQcIXVQABwFUXlQJFB8EBw8RVU4aWw4BVQsHXQBUU1EDAVwGD0NKQQ4EVl0HA1QIFTs=\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Agent],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        insecureHTTPParser: undefined,
        path: '/oauth2/token',
        _ended: true,
        res: [Circular],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        [Symbol(isCorked)]: false,
        [Symbol(outHeadersKey)]: [Object] },
     [Symbol(res)]:
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: true,
        onread: [Function: wrapper],
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onkeylog: [Function: onkeylogclient],
        onerror: [Function: onerror],
        [Symbol(owner)]: [Circular] },
     [Symbol(asyncId)]: 657637,
     [Symbol(lastWriteQueueSize)]: 0,
     [Symbol(timeout)]: null,
     [Symbol(kBytesRead)]: 0,
     [Symbol(kBytesWritten)]: 0,
     [Symbol(connect-options)]:
      { rejectUnauthorized: false,
        ciphers:
         '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,
        encoding: null,
        _agentKey:
         'enterprise-sandbox-au.simprosuite.com:443::::::::::::::::::',
        _started: true,
        agent: [Agent],
        originalHostHeaderName: 'host',
        originalHost: 'enterprise-sandbox-au.simprosuite.com',
        response: [IncomingMessage],
        ntick: true,
        href: 'https://enterprise-sandbox-au.simprosuite.com/oauth2/token',
        agentClass: [Function],
        httpModule: [Object],
        _json: true,
        path: null,
        host: 'enterprise-sandbox-au.simprosuite.com',
        port: 443,
        _jar: undefined,
        _disableCookies: true,
        originalCookieHeader: undefined,
        setHost: true,
        tunnel: true,
        proxy: null,
        uri: [Url],
        _callback: [Function: handleRequestResponse],
        __isRequestRequest: true,
        dests: [],
        pool: {},
        localAddress: undefined,
        removeHeader: [Function],
        getHeader: [Function],
        hasHeader: [Function],
        setHeader: [Function],
        _tunnel: [Tunnel],
        _redirect: [Redirect],
        _multipart: [Multipart],
        _oauth: [OAuth],
        _auth: [Auth],
        _qs: [Querystring],
        explicitMethod: true,
        writable: true,
        readable: true,
        callback: [Function],
        headers: [Object],
        method: 'post',
        _maxListeners: undefined,
        _eventsCount: 4,
        _events: [Object],
        domain: null,
        _defaultAgent: [Agent],
        servername: 'enterprise-sandbox-au.simprosuite.com',
        singleUse: true } },
  httpVersionMajor: 1,
  httpVersionMinor: 1,
  httpVersion: '1.1',
  complete: true,
  headers:
   { 'strict-transport-security': 'max-age=15768000; includeSubdomains',
     'access-control-allow-origin': '*',
     'set-cookie':
      [ 'simPRO_Session=au07~dihrn58voc8lolva9t57ompolmutgg90; path=/; domain=enterprise-sandbox-au.simprosuite.com; secure; HttpOnly' ],
     expires: 'Thu, 19 Nov 1981 08:52:00 GMT',
     'cache-control':
      'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-store',
     pragma: 'no-cache',
     'content-length': '97',
     'content-type': '',
     connection: 'close',
     date: 'Wed, 24 Nov 2021 01:13:53 GMT',
     server: 'lighttpd' },
  rawHeaders:
   [ 'Strict-Transport-Security',
     'max-age=15768000; includeSubdomains',
     'Access-Control-Allow-Origin',
     '*',
     'Set-Cookie',
     'simPRO_Session=au07~dihrn58voc8lolva9t57ompolmutgg90; path=/; domain=enterprise-sandbox-au.simprosuite.com; secure; HttpOnly',
     'Expires',
     'Thu, 19 Nov 1981 08:52:00 GMT',
     'Cache-Control',
     'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
     'Cache-Control',
     'no-store',
     'Pragma',
     'no-cache',
     'Content-Length',
     '97',
     'Content-type',
     '',
     'Connection',
     'close',
     'Date',
     'Wed, 24 Nov 2021 01:13:53 GMT',
     'Server',
     'lighttpd' ],
  trailers: {},
  rawTrailers: [],
  aborted: false,
  upgrade: false,
  url: '',
  method: null,
  statusCode: 400,
  statusMessage: 'Bad Request',
  client:
   TLSSocket {
     _tlsOptions:
      { pipe: false,
        secureContext: [SecureContext],
        isServer: false,
        requestCert: true,
        rejectUnauthorized: false,
        session: undefined,
        ALPNProtocols: undefined,
        requestOCSP: undefined },
     _secureEstablished: true,
     _securePending: false,
     _newSessionPending: false,
     _controlReleased: true,
     _SNICallback: null,
     servername: 'enterprise-sandbox-au.simprosuite.com',
     alpnProtocol: false,
     authorized: true,
     authorizationError: null,
     encrypted: true,
     _events:
      [Object: null prototype] {
        close: [Array],
        end: [Function: onReadableStreamEnd],
        newListener: [Function: keylogNewListener],
        secure: [Function: onConnectSecure],
        free: [Function: onFree],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Function: socketErrorListener],
        finish: [Function] },
     _eventsCount: 9,
     connecting: false,
     _hadError: false,
     _handle:
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: true,
        onread: [Function: wrapper],
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onkeylog: [Function: onkeylogclient],
        onerror: [Function: onerror],
        [Symbol(owner)]: [Circular] },
     _parent: null,
     _host: 'enterprise-sandbox-au.simprosuite.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,
     domain: null,
     _maxListeners: undefined,
     _writableState:
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        finalCalled: true,
        needDrain: false,
        ending: true,
        ended: true,
        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: 1,
        prefinished: false,
        errorEmitted: false,
        emitClose: false,
        autoDestroy: false,
        bufferedRequestCount: 0,
        corkedRequestsFree: [Object] },
     writable: false,
     allowHalfOpen: false,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     server: undefined,
     _server: null,
     ssl:
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: true,
        onread: [Function: wrapper],
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onkeylog: [Function: onkeylogclient],
        onerror: [Function: onerror],
        [Symbol(owner)]: [Circular] },
     _requestCert: true,
     _rejectUnauthorized: false,
     emit: [Function: wrapper],
     parser: null,
     _httpMessage:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Circular],
        connection: [Circular],
        _header:
         'POST /oauth2/token HTTP/1.1\r\nAccept: application/json\r\nreferer: http://enterprise-sandbox-au.simprosuite.com/oauth2/token\r\nhost: enterprise-sandbox-au.simprosuite.com\r\ncontent-length: 0\r\nx-newrelic-id: VgMFVVZVABACVFZSAgYOV1A=\r\nx-newrelic-transaction: PxQOV18CAQcIXVQABwFUXlQJFB8EBw8RVU4aWw4BVQsHXQBUU1EDAVwGD0NKQQ4EVl0HA1QIFTs=\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Agent],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        insecureHTTPParser: undefined,
        path: '/oauth2/token',
        _ended: true,
        res: [Circular],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        [Symbol(isCorked)]: false,
        [Symbol(outHeadersKey)]: [Object] },
     [Symbol(res)]:
      TLSWrap {
        _parent: [TCP],
        _parentWrap: undefined,
        _secureContext: [SecureContext],
        reading: true,
        onread: [Function: wrapper],
        onhandshakestart: [Function: noop],
        onhandshakedone: [Function: bound ],
        onocspresponse: [Function: onocspresponse],
        onkeylog: [Function: onkeylogclient],
        onerror: [Function: onerror],
        [Symbol(owner)]: [Circular] },
     [Symbol(asyncId)]: 657637,
     [Symbol(lastWriteQueueSize)]: 0,
     [Symbol(timeout)]: null,
     [Symbol(kBytesRead)]: 0,
     [Symbol(kBytesWritten)]: 0,
     [Symbol(connect-options)]:
      { rejectUnauthorized: false,
        ciphers:
         '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,
        encoding: null,
        _agentKey:
         'enterprise-sandbox-au.simprosuite.com:443::::::::::::::::::',
        _started: true,
        agent: [Agent],
        originalHostHeaderName: 'host',
        originalHost: 'enterprise-sandbox-au.simprosuite.com',
        response: [IncomingMessage],
        ntick: true,
        href: 'https://enterprise-sandbox-au.simprosuite.com/oauth2/token',
        agentClass: [Function],
        httpModule: [Object],
        _json: true,
        path: null,
        host: 'enterprise-sandbox-au.simprosuite.com',
        port: 443,
        _jar: undefined,
        _disableCookies: true,
        originalCookieHeader: undefined,
        setHost: true,
        tunnel: true,
        proxy: null,
        uri: [Url],
        _callback: [Function: handleRequestResponse],
        __isRequestRequest: true,
        dests: [],
        pool: {},
        localAddress: undefined,
        removeHeader: [Function],
        getHeader: [Function],
        hasHeader: [Function],
        setHeader: [Function],
        _tunnel: [Tunnel],
        _redirect: [Redirect],
        _multipart: [Multipart],
        _oauth: [OAuth],
        _auth: [Auth],
        _qs: [Querystring],
        explicitMethod: true,
        writable: true,
        readable: true,
        callback: [Function],
        headers: [Object],
        method: 'post',
        _maxListeners: undefined,
        _eventsCount: 4,
        _events: [Object],
        domain: null,
        _defaultAgent: [Agent],
        servername: 'enterprise-sandbox-au.simprosuite.com',
        singleUse: true } },
  _consuming: false,
  _dumped: false,
  req:
   ClientRequest {
     domain: null,
     _events:
      [Object: null prototype] {
        socket: [Function],
        response: [Function: bound ],
        error: [Function: bound ],
        drain: [Function],
        prefinish: [Function: requestOnPrefinish] },
     _eventsCount: 5,
     _maxListeners: undefined,
     output: [],
     outputEncodings: [],
     outputCallbacks: [],
     outputSize: 0,
     writable: true,
     _last: true,
     chunkedEncoding: false,
     shouldKeepAlive: false,
     useChunkedEncodingByDefault: true,
     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: 'enterprise-sandbox-au.simprosuite.com',
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: [TLSWrap],
        _parent: null,
        _host: 'enterprise-sandbox-au.simprosuite.com',
        _readableState: [ReadableState],
        readable: true,
        domain: null,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: false,
        allowHalfOpen: false,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [TLSWrap],
        _requestCert: true,
        _rejectUnauthorized: false,
        emit: [Function: wrapper],
        parser: null,
        _httpMessage: [Circular],
        [Symbol(res)]: [TLSWrap],
        [Symbol(asyncId)]: 657637,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: 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: 'enterprise-sandbox-au.simprosuite.com',
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: [TLSWrap],
        _parent: null,
        _host: 'enterprise-sandbox-au.simprosuite.com',
        _readableState: [ReadableState],
        readable: true,
        domain: null,
        _maxListeners: undefined,
        _writableState: [WritableState],
        writable: false,
        allowHalfOpen: false,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: [TLSWrap],
        _requestCert: true,
        _rejectUnauthorized: false,
        emit: [Function: wrapper],
        parser: null,
        _httpMessage: [Circular],
        [Symbol(res)]: [TLSWrap],
        [Symbol(asyncId)]: 657637,
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: null,
        [Symbol(kBytesRead)]: 0,
        [Symbol(kBytesWritten)]: 0,
        [Symbol(connect-options)]: [Object] },
     _header:
      'POST /oauth2/token HTTP/1.1\r\nAccept: application/json\r\nreferer: http://enterprise-sandbox-au.simprosuite.com/oauth2/token\r\nhost: enterprise-sandbox-au.simprosuite.com\r\ncontent-length: 0\r\nx-newrelic-id: VgMFVVZVABACVFZSAgYOV1A=\r\nx-newrelic-transaction: PxQOV18CAQcIXVQABwFUXlQJFB8EBw8RVU4aWw4BVQsHXQBUU1EDAVwGD0NKQQ4EVl0HA1QIFTs=\r\nConnection: close\r\n\r\n',
     _onPendingData: [Function: noopPendingOutput],
     agent:
      Agent {
        _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: 'POST',
     insecureHTTPParser: undefined,
     path: '/oauth2/token',
     _ended: true,
     res: [Circular],
     aborted: undefined,
     timeoutCb: null,
     upgradeOrConnect: false,
     parser: null,
     maxHeadersCount: null,
     [Symbol(isCorked)]: false,
     [Symbol(outHeadersKey)]:
      [Object: null prototype] {
        accept: [Array],
        referer: [Array],
        host: [Array],
        'content-length': [Array],
        'x-newrelic-id': [Array],
        'x-newrelic-transaction': [Array] } },
  request:
   Request {
     domain: null,
     _events:
      [Object: null prototype] {
        error: [Function: bound ],
        complete: [Function: bound ],
        pipe: [Array],
        response: [Function: handleGZIPResponse],
        data: [Function],
        end: [Function] },
     _eventsCount: 6,
     _maxListeners: undefined,
     method: 'post',
     headers:
      { Accept: 'application/json',
        referer: 'http://enterprise-sandbox-au.simprosuite.com/oauth2/token',
        'content-length': 0 },
     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: '55fb598c-ce9c-4b33-b7c2-a0ca6ff6d7e4',
        chunked: false,
        body: null },
     _redirect:
      Redirect {
        request: [Circular],
        followRedirect: true,
        followRedirects: true,
        followAllRedirects: false,
        allowRedirect: [Function],
        maxRedirects: 10,
        redirects: [Array],
        redirectsFollowed: 1,
        removeRefererHeader: false },
     _tunnel:
      Tunnel {
        request: [Circular],
        proxyHeaderWhiteList: [Array],
        proxyHeaderExclusiveList: [] },
     setHeader: [Function],
     hasHeader: [Function],
     getHeader: [Function],
     removeHeader: [Function],
     localAddress: undefined,
     pool: {},
     dests: [],
     __isRequestRequest: true,
     _callback: [Function: handleRequestResponse],
     uri:
      Url {
        protocol: 'https:',
        slashes: true,
        auth: null,
        host: 'enterprise-sandbox-au.simprosuite.com',
        port: 443,
        hostname: 'enterprise-sandbox-au.simprosuite.com',
        hash: null,
        search: null,
        query: null,
        pathname: '/oauth2/token',
        path: '/oauth2/token',
        href: 'https://enterprise-sandbox-au.simprosuite.com/oauth2/token' },
     proxy: null,
     tunnel: true,
     setHost: true,
     originalCookieHeader: undefined,
     _disableCookies: true,
     _jar: undefined,
     port: 443,
     host: 'enterprise-sandbox-au.simprosuite.com',
     path: '/oauth2/token',
     _json: true,
     httpModule:
      { Agent: [Function],
        globalAgent: [Agent],
        Server: [Function],
        createServer: [Function],
        get: [Function],
        request: [Function] },
     agentClass: { [Function: Agent] super_: [Function] },
     href: 'https://enterprise-sandbox-au.simprosuite.com/oauth2/token',
     ntick: true,
     response: [Circular],
     originalHost: 'enterprise-sandbox-au.simprosuite.com',
     originalHostHeaderName: 'host',
     agent:
      Agent {
        _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] },
     _started: true,
     req:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 0,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [TLSSocket],
        connection: [TLSSocket],
        _header:
         'POST /oauth2/token HTTP/1.1\r\nAccept: application/json\r\nreferer: http://enterprise-sandbox-au.simprosuite.com/oauth2/token\r\nhost: enterprise-sandbox-au.simprosuite.com\r\ncontent-length: 0\r\nx-newrelic-id: VgMFVVZVABACVFZSAgYOV1A=\r\nx-newrelic-transaction: PxQOV18CAQcIXVQABwFUXlQJFB8EBw8RVU4aWw4BVQsHXQBUU1EDAVwGD0NKQQ4EVl0HA1QIFTs=\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Agent],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        insecureHTTPParser: undefined,
        path: '/oauth2/token',
        _ended: true,
        res: [Circular],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        [Symbol(isCorked)]: false,
        [Symbol(outHeadersKey)]: [Object] },
     responseContent: [Circular],
     _destdata: true,
     _ended: true,
     _callbackCalled: true },
  toJSON: [Function: responseToJSON],
  caseless:
   Caseless {
     dict:
      { 'strict-transport-security': 'max-age=15768000; includeSubdomains',
        'access-control-allow-origin': '*',
        'set-cookie': [Array],
        expires: 'Thu, 19 Nov 1981 08:52:00 GMT',
        'cache-control':
         'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-store',
        pragma: 'no-cache',
        'content-length': '97',
        'content-type': '',
        connection: 'close',
        date: 'Wed, 24 Nov 2021 01:13:53 GMT',
        server: 'lighttpd' } },
  body:
   { error: 'invalid_request',
     error_description: 'The grant type was not specified in the request' },
  code: 400,
  status: 400,
  statusType: 4,
  info: false,
  ok: false,
  clientError: true,
  serverError: false,
  error:
   { Error: got 400 response
       at generateErrorMessage (/var/app/current/node_modules/unirest/index.js:399:23)
       at Request.handleRequestResponse [as _callback] (/var/app/current/node_modules/unirest/index.js:402:13)
       at Request.self.callback (/var/app/current/node_modules/unirest/node_modules/request/request.js:187:22)
       at Request.emit (events.js:198:13)
       at Request.EventEmitter.emit (domain.js:448:20)
       at Request.<anonymous> (/var/app/current/node_modules/unirest/node_modules/request/request.js:1044:10)
       at Request.emit (events.js:198:13)
       at Request.EventEmitter.emit (domain.js:448:20)
       at IncomingMessage.<anonymous> (/var/app/current/node_modules/unirest/node_modules/request/request.js:965:12)
       at IncomingMessage.emit (events.js:203:15)
       at IncomingMessage.EventEmitter.emit (domain.js:448:20)
       at IncomingMessage.wrapped (/var/app/current/node_modules/newrelic/lib/transaction/tracer/index.js:198:22)
       at IncomingMessage.wrappedResponseEmit (/var/app/current/node_modules/newrelic/lib/instrumentation/core/http-outbound.js:223:24)
       at endReadableNT (_stream_readable.js:1145:12)
       at Shim.applySegment (/var/app/current/node_modules/newrelic/lib/shim/shim.js:1430:20)
       at wrapper (/var/app/current/node_modules/newrelic/lib/shim/shim.js:2092:17)
       at process._tickCallback (internal/process/next_tick.js:63:19) status: 400 },
  created: false,
  accepted: false,
  nonAuthoritativeInformation: false,
  noContent: false,
  resetContent: false,
  partialContent: false,
  multiStatus: false,
  alreadyReported: false,
  imUsed: false,
  multipleChoices: false,
  movedPermanently: false,
  found: false,
  seeOther: false,
  notModified: false,
  useProxy: false,
  temporaryRedirect: false,
  permanentRedirect: false,
  badRequest: true,
  unauthorized: false,
  paymentRequired: false,
  forbidden: false,
  notFound: false,
  methodNotAllowed: false,
  notAcceptable: false,
  proxyAuthenticationRequired: false,
  requestTimeout: false,
  conflict: false,
  gone: false,
  lengthRequired: false,
  preconditionFailed: false,
  requestEntityTooLarge: false,
  uriTooLong: false,
  unsupportedMediaType: false,
  rangeNotSatisfiable: false,
  expectationFailed: false,
  misdirectedRequest: false,
  unprocessableEntity: false,
  locked: false,
  failedDependency: false,
  upgradeRequired: false,
  preconditionRequired: false,
  tooManyRequests: false,
  requestHeaderFieldsTooLarge: false,
  internalServerError: false,
  notImplemented: false,
  badGateway: false,
  serviceUnavailable: false,
  gatewayTimeout: false,
  httpVersionNotSupported: false,
  variantAlsoNegotiates: false,
  insufficientStorage: false,
  loopDetected: false,
  notExtended: false,
  cookies:
   { simPRO_Session: 'au07~dihrn58voc8lolva9t57ompolmutgg90',
     path: '/',
     domain: 'enterprise-sandbox-au.simprosuite.com',
     secure: true,
     HttpOnly: true },
  cookie: [Function],
  raw_body:
   { error: 'invalid_request',
     error_description: 'The grant type was not specified in the request' } }


Re: Oauth error - /oauth2/token api

Posted: Wed Dec 08, 2021 10:45 pm
by robbertcha
Hi Rish,

We have replied you via private message, thank you

Re: Oauth error - /oauth2/token api

Posted: Mon Dec 13, 2021 2:03 am
by rish
Thanks for helping out , the issue has been resolved.

Re: Oauth error - /oauth2/token api

Posted: Mon Jul 31, 2023 10:37 am
by AdamGrant
What was the issue? I am also seeing this