繁体   English   中英

Java - OAuth 2.0 获取访问令牌

[英]Java - OAuth 2.0 obtaining the access token

我正在编写一个简单的桌面应用程序,有时需要将压缩存档上传到 OneDrive。 这是我第一次搞砸 OAuth,我试图了解如何向用户显示登录页面并获取访问令牌。 我知道登录页面是通过这个 url 调用的: https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}&response_type=token&redirect_uri={redirect_uri} : https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}&response_type=token&redirect_uri={redirect_uri} client_id https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}&response_type=token&redirect_uri={redirect_uri} scope https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}&response_type=token&redirect_uri={redirect_uri} response_type https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}&response_type=token&redirect_uri={redirect_uri} token https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}&response_type=token&redirect_uri={redirect_uri} redirect_uri https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}&response_type=token&redirect_uri={redirect_uri}

哪个是向用户“显示”登录页面并使用 java 等待使用访问代码重定向的最佳方式?

我正在编写一个简单的桌面应用程序,有时需要将压缩存档上传到 OneDrive

您可以尝试使用设备授权授予流程

该服务将返回登录 URL 和代码。 然后你的申请

  • 打开浏览器访问返回的 URL
  • regularry 轮询令牌,如果用户登录并输入代码,则返回令牌

有多种方法可以在 java 应用程序中嵌入网页,但是您必须处理重定向 url 等。因此,对于桌面应用程序,我发现设备授权流程最容易实现。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM