upload youtube video server side(上传 youtube 视频服务器端)
问题描述
在我的应用程序中,用户可以将视频直接上传到我的 youtube 频道以将其公开.
- 我的应用程序的客户端部分获取视频并将其上传到我的服务器.
- 然后我的服务器使用 Youtube API 将视频上传到 我的 youtube 频道.
这是我的实现方式:
创建了一个新项目:
您可以在此处查看 Java 示例:https://github.com/youtube/api-samples/tree/master/java
In my application, the user can upload a video directly to my youtube channel to make it public.
- The client part of my application acquires the video and uploads it to my server.
- My server then uses Youtube API to upload the video to my youtube channel.
And here is how I implemented it:
Created a new project: https://console.developers.google.com/project
Enabled
YouTube Data API v3
:Created a
Key for server applications
:Here's my java code:
YouTube youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, new HttpRequestInitializer() { @Override public void initialize(HttpRequest httpRequest) throws IOException { } })// .setYouTubeRequestInitializer(new YouTubeRequestInitializer("XXXX"))//same as above .setApplicationName("Some Name")//is it important? .build();
The rest of the java code is the same as the code samples
But I can't get this to work, and I'm getting:
GoogleJsonResponseException code: com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
Any idea why? What Can I check?
Is the API KEY sufficient here ?
Thank you
解决方案You need a full OAuth for this, also use as installed application rather server application. And user has to go through OAuth2. Service accounts are not supported in Data API v3.
More info:https://developers.google.com/youtube/v3/guides/authentication
You can check Java samples here: https://github.com/youtube/api-samples/tree/master/java
这篇关于上传 youtube 视频服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:上传 youtube 视频服务器端


基础教程推荐
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01