必须为 oauth2 客户端指定提供商 ID?

编程入门 行业动态 更新时间:2024-10-16 08:23:30
本文介绍了必须为 oauth2 客户端指定提供商 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用 spring-boot 设置 oauth2 客户端.我对我的 pom.xml 有这个依赖:

I am trying setting up a oauth2 client with spring-boot. I have this dependencies on my pom.xml:

<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-oauth2-client</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-oauth2-jose</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> </dependencies>

我的 application.properties 上的这个配置:

this configuration on my application.properties:

spring.security.oauth2.client.registration.mercadolivre.client-id=... spring.security.oauth2.client.registration.mercadolivre.client-secret=...

和这个安全配置类:

@Configuration public class Security extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest().authenticated() .and() .oauth2Login(); } }

当我尝试运行应用程序时,出现此错误:

whe I try run the application, give me this error:

Caused by: java.lang.IllegalStateException: Provider ID must be specified for client registration 'mercadolivre' at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter.getBuilder(OAuth2ClientPropertiesRegistrationAdapter.java:95) ~[spring-boot-autoconfigure-2.2.6.RELEASE.jar!/:2.2.6.RELEASE] at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter.getClientRegistration(OAuth2ClientPropertiesRegistrationAdapter.java:61) ~[spring-boot-autoconfigure-2.2.6.RELEASE.jar!/:2.2.6.RELEASE] at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter.lambda$getClientRegistrations$0(OAuth2ClientPropertiesRegistrationAdapter.java:53) ~[spring-boot-autoconfigure-2.2.6.RELEASE.jar!/:2.2.6.RELEASE] at java.base/java.util.HashMap.forEach(HashMap.java:1338) ~[na:na] at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(OAuth2ClientPropertiesRegistrationAdapter.java:52) ~[spring-boot-autoconfigure-2.2.6.RELEASE.jar!/:2.2.6.RELEASE] at org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientRegistrationRepositoryConfiguration.clientRegistrationRepository(OAuth2ClientRegistrationRepositoryConfiguration.java:49) ~[spring-boot-autoconfigure-2.2.6.RELEASE.jar!/:2.2.6.RELEASE] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE] ... 110 common frames omitted

我在这里缺少什么?

推荐答案

您缺少用于授权的 OAuth2 提供程序,如 Spring 参考.

You're missing the OAuth2 provider you'll be authorizing with, as described in the Spring reference.

这些是您应该提供的一些属性:

Thesse are some of the properties you should provide:

spring.security.oauth2.client.registration.mercadolivre.provider=mercadolivre spring.security.oauth2.client.provider.mercadolivre.authorization-uri=... spring.security.oauth2.client.provider.mercadolivre.token-uri=...

更多推荐

必须为 oauth2 客户端指定提供商 ID?

本文发布于:2023-11-07 15:26:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566819.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:提供商   客户端   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!