2023-04-27 06:22:29 -04:00
|
|
|
// Script to create a Personal Access Token for a given user
|
|
|
|
// Example:
|
2024-10-18 07:04:57 -04:00
|
|
|
// node scripts/create_oauth_personal_access_token.mjs --user-id=643e5b240dc50c83b5bf1127
|
2023-04-27 06:22:29 -04:00
|
|
|
|
2024-10-18 07:04:57 -04:00
|
|
|
import parseArgs from 'minimist'
|
|
|
|
|
|
|
|
import OAuthPersonalAccessTokenManager from '../modules/oauth2-server/app/src/OAuthPersonalAccessTokenManager.js'
|
2023-04-27 06:22:29 -04:00
|
|
|
|
|
|
|
const argv = parseArgs(process.argv.slice(2), {
|
|
|
|
string: ['user-id'],
|
|
|
|
})
|
|
|
|
|
|
|
|
const userId = argv['user-id']
|
|
|
|
|
|
|
|
if (!userId) {
|
|
|
|
console.error('Missing --user-id argument')
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function createPersonalAccessToken() {
|
|
|
|
const accessToken = await OAuthPersonalAccessTokenManager.createToken(userId)
|
|
|
|
console.log('Personal Access Token: ' + accessToken)
|
|
|
|
}
|
|
|
|
|
2024-10-18 07:04:57 -04:00
|
|
|
try {
|
|
|
|
await createPersonalAccessToken()
|
|
|
|
process.exit()
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
process.exit(1)
|
|
|
|
}
|