簡體   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