Skip to content

Instantly share code, notes, and snippets.

@mryhryki
Last active November 4, 2025 04:20
Show Gist options
  • Save mryhryki/386ddad2d8b9816e0f04950255dca791 to your computer and use it in GitHub Desktop.
Save mryhryki/386ddad2d8b9816e0f04950255dca791 to your computer and use it in GitHub Desktop.
.env.sh
node_modules
package-lock.json
import {clientCredentialsGrant, discovery} from 'openid-client'
(async () => {
const config = await discovery({
server: new URL(process.env.SERVER_ORIGIN),
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
})
const tokens = await clientCredentialsGrant(
config,
{},
)
console.log('Token Endpoint Response', tokens)
})()
{
"name": "oauth2_client_credentials_test",
"type": "module",
"private": true,
"license": "MIT",
"author": "mryhryki",
"scripts": {
"start": "source ./.env.sh && node ./index.js"
},
"dependencies": {
"openid-client": "^6.8.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment