overleaf/services/web/scripts/create_oauth_personal_access_token.mjs
Jakob Ackermann a7517eefcb Merge pull request #21427 from overleaf/jpa-populate-db-on-import
[web] populate db with collections on import, ahead of waitForDb() call

GitOrigin-RevId: 7eb4cd61c2052187acd9947d7060f54d9822d314
2024-11-01 09:05:15 +00:00

31 lines
805 B
JavaScript

// Script to create a Personal Access Token for a given user
// Example:
// node scripts/create_oauth_personal_access_token.mjs --user-id=643e5b240dc50c83b5bf1127
import parseArgs from 'minimist'
import OAuthPersonalAccessTokenManager from '../modules/oauth2-server/app/src/OAuthPersonalAccessTokenManager.js'
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)
}
try {
await createPersonalAccessToken()
process.exit()
} catch (error) {
console.error(error)
process.exit(1)
}