I’m trying to write a key rotation script. I’ve want to rotate all keys, including self. However trying to rotate group access key returns { message: '401 Unauthorized' }
.
The same logic works with a project token, but I need to have it on the group level so I can update it for other projects as well:
let gitlab = new Gitlab(gitlabToken);
const tokens = await gitlab.getGroupAccessTokens(19); // The group with the rotator token
const key = tokens.find((token: any) => {
return token.name === 'Rotator' && token.revoked === false;
}).id;
const token = await gitlab.rotateGroupAccessToken(19, key); // This returns 401
gitlab = new Gitlab(token.token);
const t = await gitlab.updateProjectVariable(682, 'GITLAB_TOKEN', token.token);