首页 > 其他分享 >Spring Security 实战:QQ登录实现

Spring Security 实战:QQ登录实现

时间:2022-12-27 20:31:30浏览次数:59  
标签:QQ http 登录 Spring APP Security

 

准备工作

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登录 -> 个人中心,将会看到个人信息。

 

Spring Security 实战:QQ登录实现_spring

 

Spring Security 实战:QQ登录实现_github_02

 

4、删除host中添加的那一行。

 

 

 

相关说明

 

腾讯官网原话:
openid是此网站上唯一对应用户身份的标识,网站可将此ID进行存储便于用户下次登录时辨识其身份,或将其与用户在网站上的原有账号进行绑定。

 
通过QQ登录获取的 openid 用于与自己网站的账号一一对应。
 
相关文章
 
​​​Spring Security 入门:登录与退出​​​​Spring Sezzzzzzzcurity 入门:自定义 Filter​​ 
相关资料
 
​Spring Security Architecture​​​​What is authentication in Spring Security?​

 

​http://spring4all.com/article/66​



标签:QQ,http,登录,Spring,APP,Security
From: https://blog.51cto.com/u_15147537/5973533

相关文章

  • SpringBoot - 实现AOP与声明式事务
    1.实现声明式事务低版本在启动类(@SpringBootApplication)上加上@EnableTransactionManagement注解@EnableTransactionManagement注解其实在大多数情况下,不是必须的,因为S......
  • Spring AOP源码(二):BeanDefinition的准备工作
    在Spring容器中,要想创建AOP相关的对象就需要创建先准备好相关的beanDefinition信息,这里对于普通bean对象的beanDefinition准备不再赘述,仅介绍AOP的核心对象:AutoProxyCr......
  • SpringBoot - 文件上传
    Java代码@RestControllerpublicclassTestController{//单文件或多文件上传@PostMapping("/file/upload")publicStringfileUpload(@RequestParam(......
  • Spring AOP源码(一):源码分析示例
    1、aop.xml配置文件1<?xmlversion="1.0"encoding="UTF-8"?>2<beansxmlns="http://www.springframework.org/schema/beans"3xmlns:xsi="http://www.w3.......
  • SpringBoot - 全局异常处理@RestControllerAdvice,@ControllerAdvice,@ExceptionHandler
    @RestControllerAdvice与@ControllerAdvice 作用:告诉框架这是一个异常处理类,@RestControllerAdvice返回的是响应体范围:类上 @ExceptionHandler 作用:发生特定类型的......
  • SpringBoot - 目录
    SpringBoot-@Configuration,@Bean,@Scope组件注入容器SpringBoot-MVC三层架构注解注入到容器中与从IOC容器获取实例注解SpringBoot-配置包扫描注解@ComponentScanS......
  • AS3 IOC框架Spring Actionscript 的使用总结
    SpringActionscript 是众多围绕依赖注入提供解决方案的Flex控制反转框架之一AS3下经典的IOC框架有SpringActionScript、Parsley、Flicc和Swiz,由于我对JAVAspringIOC机......
  • Spring安全和角度(二)
    使用OAuth2进行单点登录在本节中,我们继续我们的讨论如何使用弹簧安全跟角在“单页应用程序”中。在这里,我们展示如何使用春季安全密钥䋰春云将我们的API网关扩展到后端......
  • SpringBoot - 自定义拦截器HandlerInterceptor
    1.实现HandlerInterceptor接口/***自定义拦截器*/publicclassMyInterceptorimplementsHandlerInterceptor{@OverridepublicbooleanpreHandle(Htt......
  • SpringBoot - 转换器Convert与SpringBoot支持的返回类型
    1.自定义转换器@Configuration(proxyBeanMethods=false)publicclassAppConfig{@BeanpublicWebMvcConfigurergetWebMvcConfigurer(){returnn......