java - 如何自动打开浏览器进行用户授权(“/回调”)?
问题描述
我正在尝试将一些视频从我的 java 服务器上传到 youtube,但我对数据授权过程有些困惑。我阅读了很多关于它的文档我无法成功地自动向用户显示授权窗口,而不是那样,我在(服务器的)控制台中收到一条消息“请在浏览器中打开以下地址:”。我必须点击它,这样用户才能看到授权窗口。
https://accounts.google.com/o/oauth2/auth?client_id=975725361259-m2pmvjv9uobcpq03tja9i66dtot7lkjv.apps.googleusercontent.com&redirect_uri=http://localhost:8081/Callback&response_type=code&scope=https://www.googleapis.com/auth/youtube.upload
我想我在这里遗漏了一些东西..
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, scopes).setCredentialDataStore(datastore)
.build();
// Build the local server and bind it to port 8081
LocalServerReceiver localReceiver = new LocalServerReceiver.Builder().setPort(8081).build();
我该如何解决它,以便用户可以自动重定向到应用程序(localhost)中的该窗口?
我错过了什么?
谢谢!
解决方案
推荐阅读
- msbuild - 如何为 Azure DevOps 多代理测试并行化将多测试 dll 拆分为每个 TestClass 的单独 dll
- android - 安装在 firestick 上时如何为我的应用设置电视横幅?
- python - Pygame迷宫一直冻结
- angular - Angular:提交带有数据和图像的表单
- excel - 如何遍历不均匀的数据块
- sql - 如何使用临时存储过程通过数据库的所有表在 SQL 中搜索值?
- python - 在 URL 的 pandas 列中查找单词的部分匹配,直接在 https:// 之后
- c++ - 如何将指向结构的指针传递给构造函数?
- python - 如何在 xarray 中设置 x,y 维度?
- nltk - 为什么 NLTK - VADER 中的 alpha 设置为 15?