@@ -30,12 +30,13 @@ const userAgent = 'actions/tool-cache'
3030 *
3131 * @param url url of tool to download
3232 * @param dest path to download tool
33+ * @param auth authorization header
3334 * @returns path to downloaded tool
3435 */
3536export async function downloadTool (
3637 url : string ,
3738 dest ?: string ,
38- token ?: string
39+ auth ?: string
3940) : Promise < string > {
4041 dest = dest || path . join ( _getTempDirectory ( ) , uuidV4 ( ) )
4142 await io . mkdirP ( path . dirname ( dest ) )
@@ -54,7 +55,7 @@ export async function downloadTool(
5455 const retryHelper = new RetryHelper ( maxAttempts , minSeconds , maxSeconds )
5556 return await retryHelper . execute (
5657 async ( ) => {
57- return await downloadToolAttempt ( url , dest || '' , token )
58+ return await downloadToolAttempt ( url , dest || '' , auth )
5859 } ,
5960 ( err : Error ) => {
6061 if ( err instanceof HTTPError && err . httpStatusCode ) {
@@ -77,7 +78,7 @@ export async function downloadTool(
7778async function downloadToolAttempt (
7879 url : string ,
7980 dest : string ,
80- token ?: string
81+ auth ?: string
8182) : Promise < string > {
8283 if ( fs . existsSync ( dest ) ) {
8384 throw new Error ( `Destination file path ${ dest } already exists` )
@@ -89,9 +90,10 @@ async function downloadToolAttempt(
8990 } )
9091
9192 let headers : IHeaders | undefined
92- if ( token ) {
93+ if ( auth ) {
94+ core . debug ( 'set auth' )
9395 headers = {
94- authorization : `token ${ token } `
96+ authorization : auth
9597 }
9698 }
9799
@@ -501,15 +503,17 @@ interface GitHubTree {
501503export async function getManifestFromRepo (
502504 owner : string ,
503505 repo : string ,
504- token : string ,
506+ auth ? : string ,
505507 branch = 'master'
506508) : Promise < IToolRelease [ ] > {
507509 let releases : IToolRelease [ ] = [ ]
508510 const treeUrl = `https://api.github.com/repos/${ owner } /${ repo } /git/trees/${ branch } `
509511
510512 const http : httpm . HttpClient = new httpm . HttpClient ( 'tool-cache' )
511- const headers : IHeaders = {
512- authorization : `token ${ token } `
513+ const headers : IHeaders = { }
514+ if ( auth ) {
515+ core . debug ( 'set auth' )
516+ headers . authorization = auth
513517 }
514518
515519 const response = await http . getJson < GitHubTree > ( treeUrl , headers )
0 commit comments