准備工作
1、在 QQ互聯 申請成為開發者,並創建應用,得到APP ID 和 APP Key。
2、了解QQ登錄時的 網站應用接入流程。(必須看完看懂)
為了方便各位測試,直接把我自己申請的貢獻出來:
APP ID : 101386962
APP Key:2a0f820407df400b84a854d054be8b6a
回調地址:http://www.ictgu.cn/login/qq
提醒:因為回調地址不是 http://localhost ,所以在啟動我提供的demo時,需要在host文件中添加一行:
127.0.0.1 www.ictgu.cn
Github 地址
https://github.com/ChinaSilenc ... urity
運行應用
1、進入 security-oauth2-qq 目錄,執行:
mvn spring-boot:run
2、此處假設你已經修改好host,並啟動成功,訪問 http://www.ictgu.cn
3、登錄 -> QQ登錄 -> 個人中心,將會看到個人信息。
4、刪除host中添加的那一行。
相關說明
騰訊官網原話:
openid是此網站上唯一對應用戶身份的標識,網站可將此ID進行存儲便於用戶下次登錄時辨識其身份,或將其與用戶在網站上的原有賬號進行綁定。
通過QQ登錄獲取的 openid 用於與自己網站的賬號一一對應。
相關文章
Spring Security 入門:登錄與退出
Spring Security 入門:自定義 Filter
相關資料
Spring Security Architecture
What is authentication in Spring Security?
http://spring4all.com/article/66