Coder Social home page Coder Social logo

venwyhk / spring-social-wechat Goto Github PK

View Code? Open in Web Editor NEW
33.0 2.0 8.0 129 KB

基于spring-social微信第三方登录实现,支持微信开放平台、微信公众平台和企业微信。

License: Apache License 2.0

Java 100.00%
spring-social wechat oauth2 java spring-boot wecom

spring-social-wechat's Introduction

Maven Central

spring-social-wechat

Installing

Production releases are available on Maven Central.

In Gradle:

implementation 'com.ikasoa:spring-social-wechat:${version}'

Or in Maven:

<dependency>
    <groupId>com.ikasoa</groupId>
    <artifactId>spring-social-wechat</artifactId>
    <version>${version}</version>
</dependency>

Properties Example

You can set multiple providers in your system.

[AppId], [AppSecret] and other parameters can be obtained from the provider website.

application.yml for WeChat Open Platform:

spring:
  social:
    wechat:
      app-id: [AppId]
      app-secret: [AppSecret]

application.yml for WeChat Official Accounts Platform:

spring:
  social:
    wechatmp: 
      app-id: [AppId]
      app-secret: [AppSecret]

application.yml for WeChat Work:

spring:
  social:
    wecom: 
      app-id: [AppId]
      agent-id: [AgentId]
      app-secret: [Secret]

Providers and Parameters:

Provider Name Provider Id Authorization Type Parameters Required
(if you use this platform)
Default
WeChat Open Platform wechat QR Code spring.social.wechat.app-id yes
spring.social.wechat.app-secret yes
spring.social.wechat.check-state no true
WeChat Official Accounts Platform wechatmp Webpage spring.social.wechatmp.app-id yes
spring.social.wechatmp.app-secret yes
spring.social.wechatmp.check-state no true
WeChat Work wecom QR Code spring.social.wecom.app-id yes
spring.social.wecom.agent-id yes
spring.social.wecom.app-secret yes
spring.social.wechat.check-state no true

HTML Example

This [ProviderId] must be 'wechat', 'wechatmp' or 'wecom'. It depends on the provider you choose. (please refer to the table above)

<form action="/signin/[ProviderId]" method="POST">
    <button type="submit">Log in</button>
</form>

Sample

spring-social-wechat-sample


  

spring-social-wechat's People

Contributors

venwyhk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

spring-social-wechat's Issues

如何配置redirect_uri?

您好,

我在项目中使用了您开发的这个库做微信登录,非常好用,很感谢您的分享。
目前我遇到了一个问题:我们的项目是部署在Docker容器里运行的,当用户点击“微信登录”时,系统通过这个库被定向到微信开放平台的URL,URL里面的redirect_uri被自动生成为Docker容器的内部IP,如“https%3A%2F%2F172.16.16.60%3A8443%2Fsp%2Fsignin%2F”,而实际正确的redirect_uri应该是https%3A%2F%2Fwww.hotcloud.tech%2Fsp%2Fsignin%2F。请问目前这个库可以对redirect_uri进行配置吗,这样我们可以配置正确的redirect_uri?

谢谢,

如何接入移动应用

看示例代码讲的是如何接入网站应用,移动应用和网站应用还是有一些区别的,例如移动应用里面似乎就没有携带code的redirect url,那这时候应该如何修改适应移动应用的微信登陆?

关于springboot版本的问题

simple项目中使用的springboot版本是1.5.22.RELEASE,现在我用最新版本的springboot提示

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.wechat.demo.Application]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/social/SocialAutoConfigurerAdapter.class] cannot be opened because it does not exist
	at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:609) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:310) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:249) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:206) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:174) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at com.wechat.demo.Application.main(Application.java:22) [classes/:na]
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/social/SocialAutoConfigurerAdapter.class] cannot be opened because it does not exist
	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[spring-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:55) ~[spring-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:49) ~[spring-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[spring-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:86) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:73) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81) ~[spring-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:695) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getSuperClass(ConfigurationClassParser.java:1009) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:340) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:249) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:371) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:271) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:249) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:599) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	... 17 common frames omitted

有解决办法吗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.