fix: pass OAuth token explicitly to avoid config token overwrite
Signed-off-by: ElaineDeMattosSilvaB <elaine.de-mattos-silva-bezerra@deutschebahn.com>
This commit is contained in:
@@ -340,10 +340,7 @@ export class GitlabUrlReader implements UrlReaderService {
|
||||
);
|
||||
}
|
||||
// Default to the old behavior of assuming the url is for a file
|
||||
return getGitLabFileFetchUrl(target, {
|
||||
...this.integration.config,
|
||||
...(token && { token }),
|
||||
});
|
||||
return getGitLabFileFetchUrl(target, this.integration.config, token);
|
||||
}
|
||||
|
||||
// convert urls of the form:
|
||||
|
||||
@@ -40,8 +40,9 @@ import {
|
||||
export async function getGitLabFileFetchUrl(
|
||||
url: string,
|
||||
config: GitLabIntegrationConfig,
|
||||
token?: string,
|
||||
): Promise<string> {
|
||||
const projectID = await getProjectId(url, config);
|
||||
const projectID = await getProjectId(url, config, token);
|
||||
return buildProjectUrl(url, projectID, config).toString();
|
||||
}
|
||||
|
||||
@@ -113,6 +114,7 @@ export function buildProjectUrl(
|
||||
export async function getProjectId(
|
||||
target: string,
|
||||
config: GitLabIntegrationConfig,
|
||||
token?: string,
|
||||
): Promise<number> {
|
||||
const url = new URL(target);
|
||||
|
||||
@@ -143,7 +145,7 @@ export async function getProjectId(
|
||||
|
||||
const response = await fetch(
|
||||
repoIDLookup.toString(),
|
||||
getGitLabRequestOptions(config),
|
||||
getGitLabRequestOptions(config, token),
|
||||
);
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user