Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
eranturgeman committed Dec 31, 2023
1 parent 71cbe15 commit d1a7421
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 47 deletions.
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function main() {
try {
core.startGroup('Setup JFrog CLI');
utils_1.Utils.setCliEnv();
console.log("ERAN CHECK: ####################### 1 #######################"); // TODO del
console.log("ERAN CHECK: ####################### 2 #######################"); // TODO del
console.log("ERAN CHECK: starting access Token flow"); // TODO del
let accessToken = yield utils_1.Utils.getJfrogAccessToken();
console.log(`ERAN CHECK: finished access token flow with access token: ${accessToken}`); // TODO del
Expand Down
28 changes: 6 additions & 22 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,42 +97,26 @@ class Utils {
assertion: jsonWebToken,
aud: audience
});
// #########
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
};
// ######
/*
const additionalHeaders : string = JSON.stringify({
'Content-Type': 'application/x-www-form-urlencoded',
});
*/
console.log(`ERAN CHECK: starting POST`); // TODO del
const response = yield httpClient.post(exchangeUrl, dataString);
const response = yield httpClient.post(exchangeUrl, dataString, headers);
console.log(`ERAN CHECK: POST succeeded`); // TODO del
const responseData = yield response.readBody();
console.log(`ERAN CHECK: response string: ${responseData}`); // TODO del
}
catch (error) {
throw new Error(`POST REST command failed with error ${error.message}`);
}
/*
const response = await fetch(exchangeUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${jsonWebToken}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
aud: audience
}),
});
if(!response.ok) {
throw new Error(`POST REST command failed with status ${response.status}`)
}
const responseData = await response.json();
console.log(responseData)
console.log(`ERAN CHECK: REST response JSON is: \n ${responseData}`)
*/
// TODO print the json content in order to ensure the fields name
return "";
});
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async function main() {
try {
core.startGroup('Setup JFrog CLI');
Utils.setCliEnv();
console.log("ERAN CHECK: ####################### 1 #######################") // TODO del
console.log("ERAN CHECK: ####################### 2 #######################") // TODO del
console.log("ERAN CHECK: starting access Token flow") // TODO del
let accessToken = await Utils.getJfrogAccessToken()
console.log(`ERAN CHECK: finished access token flow with access token: ${accessToken}`) // TODO del
Expand Down
30 changes: 7 additions & 23 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,43 +99,27 @@ export class Utils {
aud: audience
});

// #########
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
}
// ######

/*
const additionalHeaders : string = JSON.stringify({
'Content-Type': 'application/x-www-form-urlencoded',
});
*/
console.log(`ERAN CHECK: starting POST`) // TODO del
const response: HttpClientResponse = await httpClient.post(exchangeUrl, dataString)
const response: HttpClientResponse = await httpClient.post(exchangeUrl, dataString, headers)
console.log(`ERAN CHECK: POST succeeded`) // TODO del
const responseData: string = await response.readBody()
console.log(`ERAN CHECK: response string: ${responseData}`) // TODO del

} catch (error : any) {
throw new Error(`POST REST command failed with error ${error.message}`)
}

/*
const response = await fetch(exchangeUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${jsonWebToken}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
aud: audience
}),
});
if(!response.ok) {
throw new Error(`POST REST command failed with status ${response.status}`)
}
const responseData = await response.json();
console.log(responseData)
console.log(`ERAN CHECK: REST response JSON is: \n ${responseData}`)
*/
// TODO print the json content in order to ensure the fields name
return ""
}
Expand Down

0 comments on commit d1a7421

Please sign in to comment.