用Java实现QQ登录

Java实现QQ登录

写了一个个人网站,增加一个登录的地方,自己写登录太麻烦,而且用户一般也不愿意去登录,接入QQ互联,实现QQ一键登录。所有前提是你得有一个IP地址和域名。
==ps:==用处不大,主要是写着玩
QQ登录

1 进入qq互联官网进入点击头像个创建提交申请
点击头像进入

2 选择个人接入,按照步骤填写注册资料
填写接入信息创建成功通过后会哦显示接入的个人信息。

3 审核成功后点击下面的开始创建,按步骤完成创建过程。
点击开始创建

4 创建成功后可以查看APP IDAPP 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.com/
getUserInfoURL = https://graph.qq.com/user/get_user_info
accessTokenURL = https://graph.qq.com/oauth2.0/token
authorizeURL = https://graph.qq.com/oauth2.0/authorize
getOpenIDURL = https://graph.qq.com/oauth2.0/me
addTopicURL = https://graph.qq.com/shuoshuo/add_topic
addBlogURL = https://graph.qq.com/blog/add_one_blog
addAlbumURL = https://graph.qq.com/photo/add_album
uploadPicURL = https://graph.qq.com/photo/upload_pic
listAlbumURL = https://graph.qq.com/photo/list_album
addShareURL = https://graph.qq.com/share/add_share
checkPageFansURL = https://graph.qq.com/user/check_page_fans
addTURL = https://graph.qq.com/t/add_t
addPicTURL = https://graph.qq.com/t/add_pic_t
delTURL = https://graph.qq.com/t/del_t
getWeiboUserInfoURL = https://graph.qq.com/user/get_info
getWeiboOtherUserInfoURL = https://graph.qq.com/user/get_other_info
getFansListURL = https://graph.qq.com/relation/get_fanslist
getIdolsListURL = https://graph.qq.com/relation/get_idollist
addIdolURL = https://graph.qq.com/relation/add_idol
delIdolURL = https://graph.qq.com/relation/del_idol
getTenpayAddrURL = https://graph.qq.com/cft_info/get_tenpay_addr
getRepostListURL = https://graph.qq.com/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.com/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
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值