問題描述
LinkedIn OAuth2.0 使會話無效/強制重新授權 (LinkedIn OAuth2.0 Invalidate Session / Force re‑authorization)
我剛剛在我的應用程序中從 LinkedIn 的 JavaScript SDK 遷移到他們的 OAuth2.0 授權流程,因為他們在 3 月份宣布棄用他們的 SDK。
身份驗證流程按預期工作。問題是我找不到任何有關如何強制重新身份驗證或使當前用戶的訪問令牌無效的文檔。以前的 JavaScript SDK 有一個 IN.User.logout()
方法,我用來允許重新認證,而這在使用 OAuth2.0 流程時是不可用的。這會給在共享計算機/瀏覽器上登錄的用戶帶來問題。
以下是我發現重新身份驗證在哪裡啟動的一些方法,但我的應用程序無法自行完成:
- 清除網絡瀏覽器/LinkedIn cookie
- 直接註銷 LinkedIn 網站
- 更新/更改請求的權限(不理想)
有沒有人建議我如何強制重新應用程序中的身份驗證?或者這是不可能的,除非 LinkedIn 實現了一個端點來使令牌無效?
希望 LinkedIn 的某個人可能能夠對此進行干預,以及他們希望開發人員如何處理這種情況,因為他們指向 Stack Overflow 尋求支持.
參考資料
更新 [2/12/19]:我已經就這個問題直接聯繫了 LinkedIn,他們繼續將我引導到這裡並堅持讓我重新發布這個問題。希望LinkedIn的人仍然會看到這個,但假設它不會很快得到答复。必須假設 v2 API 中不存在失效。
參考解法
方法 1:
I had same suffering as you, so I started with all possible combinations of requests until I managed to revoke token, this is the request:
curl ‑‑request POST \
‑‑url https://www.linkedin.com/oauth/v2/revoke \
‑‑header 'Content‑Type: application/x‑www‑form‑urlencoded' \
‑‑data client_id=CLIENT_ID_HERE \
‑‑data client_secret=CLIENT_SECRET_HERE \
‑‑data token=YOUR_TOKEN_HERE
(by jalamak、Srđan Radiša)