io.tus.java.client.ProtocolException: unexpected status code (403) while creating upload
idoor88 opened this issue · 1 comments
Hi, I tried to use this library to upload a video file to my youtube account, the file is a .mp4 on my android phone, when I executed the following code, I got this error:
io.tus.java.client.ProtocolException: unexpected status code (403) while creating upload
Here is the code:
`
let uploadUrl = "https://www.googleapis.com/upload/youtube/v3/videos?part=snippet,status&uploadType=resumable&key=xxxxxxxx";
let filePath='/storage/emulated/0/DCIM/Camera/test.mp4';
const upload = new Upload(filePath, {
endpoint: uploadUrl,
retryDelays: [0, 1000, 3000, 5000],
headers: {'Authorization': 'Bearer ' + mytoken},
metadata: {
filename: filePath,
filetype: 'application/octet-stream',
snippet:
{ "title":"Testing",
"description":"This is to show an example",
"categoryId":"22",
"tags":["Cut","Cat"]
},
status:
{ "privacyStatus":"unlisted",
"embeddable":true,
"license":"youtube"
}
},
onError: (error) => {
console.log("Upload error:", error);
},
onProgress: (uploadedBytes, totalBytes) => {
console.log("uploadedBytes, totalBytes: ", uploadedBytes, totalBytes);
},
onSuccess: () => {
console.log("Upload upload:", upload);
}
});
upload.start();
`
System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Memory: 163.24 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.4.0 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 27.0.3, 28.0.2, 28.0.3
System Images: android-22 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.1 AI-173.4907809
Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
npmPackages:
react: ^16.8.6 => 16.8.6
react-native: ^0.60.0 => 0.60.0
npmGlobalPackages:
react-native-asset: 2.0.0
react-native-cli: 2.0.1
react-native-cn-richtext-editor: 1.0.33
react-native-git-upgrade: 0.2.7