Fehler beim Versuch, eine Webanwendung mit OAuth2 und Strava mit Spring Start zu authentifizierenJava

Java-Forum
Anonymous
 Fehler beim Versuch, eine Webanwendung mit OAuth2 und Strava mit Spring Start zu authentifizieren

Post by Anonymous »

Ich versuche Strawa zu verwenden, um Kunden zu authentifizieren, die meine Webanwendung mit Spring Boot verwenden möchten, und ich stecke in diesem Fehler fest: < /p>

.s.o.c.w. oauth2LoginauthenticationFilter < /strong>: Authentifizierungsanforderung
fehlgeschlagen:
org.springframework.security.oauth2.core.oauth2AuthenticationException:
[Invaly_Token_Response] Es ist ein Fehler beim Versuch, die Antwort von OAUTH 2.0 Access -Token zu reichen: Es konnte keine Antwort extrahieren: keine geeignete geeignete geeignete Reaktion: Keine geeigneten geeigneten geeigneten Reaktion: Keine geeigneten geeigneten Reaktion: Keine geeigneten geeigneten Reaktion. httpMessageConverter < /strong> für Reaktionstyp
[Klasse
org.springFramework.security.oauth2.core.endpoint.oauth2AccessTokenResponse
weibliche und Inhaltstyp [text/html]

Ich würde mich über jede Hilfe freuen, um diesen Fehler voranzutreiben und zu lösen. Ich habe die Reproduktion des Fehlers auf nur 2 Klassen vereinfacht: < /p>

Code: Select all

DemoSecurity.java extending WebSecurityConfigurerAdapter
DemoApplication.java as the entry to the application with @SpringBootApplication,
und Sie müssen eine App mit Strava (https://www.strava.com/setings/api) registrieren, um Ihr client_secret und client_id . In Strava muss der Rückruf als localhost hinzugefügt werden, um diesen Test auszuführen. /localhost: 8080/Login in Ihrem Browser. />

Code: Select all

spring:
security:
oauth2:
client:
registration:
strava:
provider: strava-provider
client-id: XXXXX
client-secret: XXXXXXXXXXXXXXXXX
client-authentication-method: POST
authorization-grant-type: authorization_code
redirect-uri: http://localhost:8080/login/oauth2/code/
scope:
- read
provider:
strava-provider:
tokenUri: https://www.strava.com/api/v3/oauth/token/
authorizationUri: https://www.strava.com/api/v3/oauth/authorize?response_type=code
< /code>
Dies ist mein pom.xml: < /p>

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

org.springframework.boot
spring-boot-starter-parent
2.3.1.RELEASE
 

com.example
demo
0.0.1-SNAPSHOT
demo
Demo project for Spring Boot


1.8




org.springframework.boot
spring-boot-starter-oauth2-client


org.springframework.boot
spring-boot-starter-web



org.springframework.boot
spring-boot-starter-test
test


org.junit.vintage
junit-vintage-engine








org.springframework.boot
spring-boot-maven-plugin



< /code>

Dies ist meine DemoApplication.java:
package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;

@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}

}
< /code>
Dies ist meine Demosecurity.java:
package com.example.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@EnableWebSecurity
@Configuration
public class DemoSecurity extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/login**","/", "/error", "/webjars/**").permitAll()
.anyRequest()
.authenticated().and()
.oauth2Login()
;
}

}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post