Sorry for the lack of information.
I will post additional information below.
OAuth clients never lack privileges.
If you can tell us what you can find out, we would appreciate it.
As for the execution, we are doing the following.
This is an error in this section.
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
async function getAccessToken() {
try {
// クライアント資格情報でログイン
const res = await client.loginClientCredentialsGrant(clientId, clientSecret);
// ログイン後にアクセストークンを取得
const accessToken = res.accessToken;
return accessToken;
} catch (err) {
console.error('アクセストークンの取得に失敗しました:', err);
// ログファイルを作成する
const logLv = '[ERROR ]'; // logOutput()ログレベルメッセージ
const msg = トークンAPI機能:${err}
; // logOutput()引数任意メッセージ
await logOutput(logLv, msg); // logOutput()ログ出力関数に引数を渡す
throw new error('処理が失敗しました');
}
}
‐‐‐‐‐‐‐‐‐‐‐‐‐‐
The error is as follows
The information part of Proxy and Authorization
is replaced by xxxx and information.
‐‐‐‐‐‐‐‐‐‐‐‐
2025-02-24T14:24:10.270Z ea19df68-46cb-4e3e-9c8a-1f6fda1cd957 ERROR アクセストークンの取得に失敗しました: AxiosError: Bad response: 403
at AxiosError.from (/opt/nodejs/node_modules/axios/dist/node/axios.cjs:877:14)
at RedirectableRequest.handleRequestError (/opt/nodejs/node_modules/axios/dist/node/axios.cjs:3163:25)
at RedirectableRequest.emit (node:events:519:28)
at RedirectableRequest.emit (node:domain:488:12)
at eventHandlers. (/opt/nodejs/node_modules/follow-redirects/index.js:49:24)
at ClientRequest.emit (node:events:519:28)
at ClientRequest.emit (node:domain:488:12)
at emitErrorEvent (node:_http_client:101:11)
at _destroy (node:_http_client:884:9)
at onSocketNT (node:_http_client:904:5)
at Axios.request (/opt/nodejs/node_modules/axios/dist/node/axios.cjs:4252:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [ 'xhr', 'http', 'fetch' ],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function], Blob: [class Blob] },
validateStatus: [Function: validateStatus],
headers: Object [AxiosHeaders] {
Accept: 'application/json, text/plain, /',
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: 'Basic xxxxxxxxxxxxxxxxxxxxx=',
'User-Agent': 'axios/1.7.9',
'Content-Length': '29',
'Accept-Encoding': 'gzip, compress, deflate, br'
},
method: 'post',
url: 'https://login.mypurecloud.jp/oauth/token',
data: 'grant_type=client_credentials',
httpsAgent: HttpsProxyAgent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object: null prototype],
requests: [Object: null prototype] {},
sockets: [Object: null prototype],
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 0,
maxCachedSessions: 100,
_sessionCache: [Object],
proxy: URL {},
proxyRequestOptions: {},
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
}
},
request: <ref *1> Writable {
_events: {
close: undefined,
error: [Function: handleRequestError],
prefinish: undefined,
finish: undefined,
drain: undefined,
response: [Function: handleResponse],
socket: [Function: handleRequestSocket]
},
_writableState: WritableState {
highWaterMark: 16384,
length: 0,
corked: 0,
onwrite: [Function: bound onwrite],
writelen: 0,
bufferedIndex: 0,
pendingcb: 0,
[Symbol(kState)]: 17580812,
[Symbol(kBufferedValue)]: null
},
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: Infinity,
protocol: 'https:',
path: 'https://login.mypurecloud.jp/oauth/token',
method: 'POST',
headers: [Object: null prototype],
agents: [Object],
auth: undefined,
family: undefined,
beforeRedirect: [Function: dispatchBeforeRedirect],
beforeRedirects: [Object],
hostname: 'xxxxxx',
port: '8080',
agent: [HttpsProxyAgent],
nativeProtocols: [Object],
pathname: 'https://login.mypurecloud.jp/oauth/token'
},
_ended: false,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 29,
_requestBodyBuffers: [ [Object] ],
_eventsCount: 3,
_onNativeResponse: [Function (anonymous)],
_currentRequest: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [Array],
outputSize: 448,
writable: true,
destroyed: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: '29',
_hasBody: true,
_trailer: '',
finished: false,
_headerSent: true,
_closed: true,
socket: null,
_header: 'POST https://login.mypurecloud.jp/oauth/token HTTP/1.1\r\n' +
'Accept: application/json, text/plain, /\r\n' +
'Content-Type: application/x-www-form-urlencoded\r\n' +
'Authorization: Basic xxxxxxxxxxxxxxxxxxxxx=\r\n' +
'User-Agent: axios/1.7.9\r\n' +
'Content-Length: 29\r\n' +
'Accept-Encoding: gzip, compress, deflate, br\r\n' +
'host: login.mypurecloud.jp\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [HttpsProxyAgent],
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: 'https://login.mypurecloud.jp/oauth/token',
_ended: false,
res: null,
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'xxxxxx',
protocol: 'https:',
_redirectable: [Circular *1],
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(errored)]: null,
[Symbol(kHighWaterMark)]: 16384,
[Symbol(kRejectNonStandardBodyWrites)]: false,
[Symbol(kUniqueHeaders)]: null
},
_currentUrl: 'https://login.mypurecloud.jp/oauth/token',
[Symbol(shapeMode)]: true,
[Symbol(kCapture)]: false
},
cause: Error: Bad response: 403
at ClientRequest. (/opt/nodejs/node_modules/hpagent/index.js:106:18)
at Object.onceWrapper (node:events:634:26)
at ClientRequest.emit (node:events:519:28)
at ClientRequest.emit (node:domain:488:12)
at Socket.socketOnData (node:_http_client:584:11)
at Socket.emit (node:events:519:28)
at Socket.emit (node:domain:488:12)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5)
}