Cool, ya was just using fetch…
export async function GetAuth0AccessToken() {
const url = `${process.env.AUTH0_ISSUER_BASE_URL}` + "/oauth/token";
const payload = {
"grant_type" : "client_credentials",
"client_id" : `${process.env.AUTH0_CLIENT_TOKEN_ID}`,
"client_secret" : `${process.env.AUTH0_CLIENT_TOKEN_SECRET}`,
"audience" : `${process.env.AUTH0_CLIENT_AUDIENCE}`
}
const headers = {
'content-type' : 'application/json'
}
try {
const response = await fetch(url, {
method: 'POST',
headers,
body: JSON.stringify(payload),
});
if (response.ok) {
console.log(response)
} else {
const errorData = await response.text();
console.log(errorData)
}
} catch (error) {
console.log('Internal Server Error')
}
}
Payload I get back:
Response {
[Symbol(realm)]: null,
[Symbol(state)]: {
aborted: false,
rangeRequested: false,
timingAllowPassed: true,
requestIncludesCredentials: true,
type: ‘default’,
status: 200,
timingInfo: {
startTime: 1217396.2971999645,
redirectStartTime: 0,
redirectEndTime: 0,
postRedirectStartTime: 1217396.2971999645,
finalServiceWorkerStartTime: 0,
finalNetworkResponseStartTime: 0,
finalNetworkRequestStartTime: 0,
endTime: 0,
encodedBodySize: 2,
decodedBodySize: 0,
finalConnectionTimingInfo: null
},
cacheState: ‘’,
statusText: ‘OK’,
headersList: HeadersList {
cookies: [Array],
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: null
},
urlList: [ [URL] ],
body: { stream: undefined }
},
[Symbol(headers)]: HeadersList {
cookies: [
‘did=s%3Av0%3Ad9beb930-57e0-11ee-bc39-3903e846145d.GOfR8UnQKK%2FSbYMQPKTHOZqj1X5i%2FLmCY2s%2BcfYcw3U; Max-Age=31557600; Path=/; Expires=Fri, 20 Sep 2024 00:09:33 GMT; HttpOnly; Secure; SameSite=None’,
‘did_compat=s%3Av0%3Ad9beb930-57e0-11ee-bc39-3903e846145d.GOfR8UnQKK%2FSbYMQPKTHOZqj1X5i%2FLmCY2s%2BcfYcw3U; Max-Age=31557600; Path=/; Expires=Fri, 20 Sep 2024 00:09:33 GMT; HttpOnly; Secure’
],
[Symbol(headers map)]: Map(25) {
‘date’ => [Object],
‘content-type’ => [Object],
‘transfer-encoding’ => [Object],
‘connection’ => [Object],
‘cf-ray’ => [Object],
‘cf-cache-status’ => [Object],
‘cache-control’ => [Object],
‘set-cookie’ => [Object],
‘strict-transport-security’ => [Object],
‘vary’ => [Object],
‘ot-baggage-auth0-request-id’ => [Object],
‘ot-tracer-sampled’ => [Object],
‘ot-tracer-spanid’ => [Object],
‘ot-tracer-traceid’ => [Object],
‘pragma’ => [Object],
‘traceparent’ => [Object],
‘tracestate’ => [Object],
‘x-auth0-requestid’ => [Object],
‘x-content-type-options’ => [Object],
‘x-ratelimit-limit’ => [Object],
‘x-ratelimit-remaining’ => [Object],
‘x-ratelimit-reset’ => [Object],
‘server’ => [Object],
‘content-encoding’ => [Object],
‘alt-svc’ => [Object]
},
[Symbol(headers map sorted)]: null
}
}