mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 04:45:21 -05:00
d2172e5179
* [web] Issue Oauth2 access tokens * [web] Add partial index for `oauthAccessTokens.user_id` for Personal Access Tokens * [web] script to create personal access tokens GitOrigin-RevId: 796e8d23a6799a87ac6096c686139c6290668b83
33 lines
911 B
JavaScript
33 lines
911 B
JavaScript
// Script to create a Personal Access Token for a given user
|
|
// Example:
|
|
// node scripts/create_oauth_personal_access_token.js --user-id=643e5b240dc50c83b5bf1127
|
|
|
|
const parseArgs = require('minimist')
|
|
const { waitForDb } = require('../app/src/infrastructure/mongodb')
|
|
const OAuthPersonalAccessTokenManager = require('../modules/oauth2-server/app/src/OAuthPersonalAccessTokenManager')
|
|
|
|
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() {
|
|
await waitForDb()
|
|
const accessToken = await OAuthPersonalAccessTokenManager.createToken(userId)
|
|
console.log('Personal Access Token: ' + accessToken)
|
|
}
|
|
|
|
createPersonalAccessToken()
|
|
.then(() => {
|
|
process.exit()
|
|
})
|
|
.catch(err => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|