admin管理员组文章数量:1531793
Java实现QQ登录
写了一个个人网站,增加一个登录的地方,自己写登录太麻烦,而且用户一般也不愿意去登录,接入QQ互联,实现QQ一键登录。所有前提是你得有一个IP地址和域名。
==ps:==用处不大,主要是写着玩
1 进入qq互联官网进入点击头像个创建提交申请
2 选择个人接入,按照步骤填写注册资料
创建成功通过后会哦显示接入的个人信息。
3 审核成功后点击下面的开始创建,按步骤完成创建过程。
4 创建成功后可以查看APP ID
和APP key
,很重要
在应用管理界面可以查看如上信息,点击查看就可以看到如下关键信息。
往下划在平台信息里可以看到网站地址和网站回调域,回调域一般是`@requestMapping()``中写的请求地址
5 登录页面
<a href"/login">qq登录</a>
6 配置qqconnectconfig.properties
,与application.properties
同一级
app_ID = 你的App ID
app_KEY = 你的App key
redirect_URI = 你的回调域
scope = get_user_info,add_topic,add_one_blog,add_album,upload_pic,list_album,add_share,check_page_fans,add_t,add_pic_t,del_t,get_repost_list,get_info,get_other_info,get_fanslist,get_idollist,add_idol,del_ido,get_tenpay_addr
baseURL = https://graph.qq/
getUserInfoURL = https://graph.qq/user/get_user_info
accessTokenURL = https://graph.qq/oauth2.0/token
authorizeURL = https://graph.qq/oauth2.0/authorize
getOpenIDURL = https://graph.qq/oauth2.0/me
addTopicURL = https://graph.qq/shuoshuo/add_topic
addBlogURL = https://graph.qq/blog/add_one_blog
addAlbumURL = https://graph.qq/photo/add_album
uploadPicURL = https://graph.qq/photo/upload_pic
listAlbumURL = https://graph.qq/photo/list_album
addShareURL = https://graph.qq/share/add_share
checkPageFansURL = https://graph.qq/user/check_page_fans
addTURL = https://graph.qq/t/add_t
addPicTURL = https://graph.qq/t/add_pic_t
delTURL = https://graph.qq/t/del_t
getWeiboUserInfoURL = https://graph.qq/user/get_info
getWeiboOtherUserInfoURL = https://graph.qq/user/get_other_info
getFansListURL = https://graph.qq/relation/get_fanslist
getIdolsListURL = https://graph.qq/relation/get_idollist
addIdolURL = https://graph.qq/relation/add_idol
delIdolURL = https://graph.qq/relation/del_idol
getTenpayAddrURL = https://graph.qq/cft_info/get_tenpay_addr
getRepostListURL = https://graph.qq/t/get_repost_list
version = 2.0.0.0
7导入依赖
<!--热部署工具-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<!--QQ登录-->
<!-- https://mvnrepository/artifact/net.gplatform/Sdk4J -->
<dependency>
<groupId>net.gplatform</groupId>
<artifactId>Sdk4J</artifactId>
<version>2.0</version>
</dependency>
8 编写controller
//获取用户当前页面的url,方便返回登录之前的页面,
private static String returnUrl = ""
/**
* @Description: qq登录的入口
*/
@GetMapping("/login")
public ResponseEntity<Void> loginByQQ(HttpServletRequest request, HttpServletResponse response){
returnUrl = request.getParamet
版权声明:本文标题:用Java实现QQ登录 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1725629626a1033614.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论