tauri-apps / tauri-apps/plugins-workspace
[bug] Upload Plugin not using Authorization Header
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
### Describe the bug
When using the release asset url of a **_public_** repository, the download API correctly start downloading the file.
When using the @tauri-apps/plugin-upload [`download`](https://tauri.app/reference/javascript/upload/#download/) function to get a _**private**_ GitHub repositories release asset, the request responds with:
`
error sending request for url (https://api.github.com/repos/USER/REPO/releases/assets/ASST_ID)
`
### Reproduction
1. Install the plugin and import the JavaScript API.
2. Call the API with the following:
a. URL: the api.github.com download url of a private release assets (see: https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#get-a-release-asset)
b. TOKEN: pass your github Personal access token as the Authorization header
This is how I have implemented this plugin using a React frontend:
```
import { download } from '@tauri-apps/plugin-upload';
export function DownloadComponent() {
useEffect(() => {
downloadFile();
}, []);
async function downloadFile() {
const path = './download/fileName.zip';
const url = 'https://api.github.com/repos/USER/REPO/releases/assets/ASST_ID';
await download(
url,
path,
progress,
new Map([[ 'Authorization', 'token GITHUB_TOKEN' ]])
);
}
function progress({ progressTotal, total }: any ) {
console.log('progressTotal: ' + progressTotal + ', total: ' + total);
}
return (
Downloading...
);
}
```


### Expected behavior
The download function should pass the auth header to the requested url and begin downloading the contents of the file.
### Full `tauri info` output
```text
[✔] Environment
- OS: Windows 10.0.26100 x86_64 (X64)
✔ WebView2: 133.0.3065.92
✔ MSVC:
- Visual Studio Build Tools 2022
- Visual Studio Community 2022
✔ rustc: 1.84.0 (9fc6b4312 2025-01-07)
✔ cargo: 1.84.0 (66221abde 2024-11-19)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.11.0
- npm: 10.2.4
- bun: 1.2.5
[-] Packages
- tauri 🦀: 2.2.3
- tauri-build 🦀: 2.0.5
- wry 🦀: 0.48.1
- tao 🦀: 0.31.1
- @tauri-apps/api : 2.3.0
- @tauri-apps/cli : 2.3.1
[-] Plugins
- tauri-plugin-autostart 🦀: 2.2.0
- @tauri-apps/plugin-autostart : 2.2.0
- tauri-plugin-process 🦀: 2.2.0
- @tauri-apps/plugin-process : 2.2.0
- tauri-plugin-upload 🦀: 2.2.1
- @tauri-apps/plugin-upload : 2.2.1
- tauri-plugin-shell 🦀: 2.2.0
- @tauri-apps/plugin-shell : 2.2.0
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
```
### Stack trace
```
N/A
```
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.