feat: gitlab triggers integration

This commit is contained in:
Krzysztof Dukszta-Kwiatkowski
2023-05-15 11:22:37 +02:00
committed by Ali BARIN
parent 93a2e2151e
commit 3f8f022d48
45 changed files with 2130 additions and 12 deletions

View File

@@ -0,0 +1,24 @@
import { IGlobalVariable } from '@automatisch/types';
import { URLSearchParams } from 'url';
const refreshToken = async ($: IGlobalVariable) => {
// ref: https://docs.gitlab.com/ee/api/oauth2.html#authorization-code-flow
const params = new URLSearchParams({
grant_type: 'refresh_token',
client_id: $.auth.data.clientId as string,
client_secret: $.auth.data.clientSecret as string,
refresh_token: $.auth.data.refreshToken as string,
});
const { data } = await $.http.post('/oauth/token', params.toString());
await $.auth.set({
accessToken: data.access_token,
expiresIn: data.expires_in,
tokenType: data.token_type,
refreshToken: data.refresh_token,
});
};
export default refreshToken;