我正在开发一个相当简单的spring引导API,它将由oauth2来保护。所有端点都能很好地接受应用程序/json请求,但默认的spring /oauth/*端点除外,这些端点似乎需要请求内容类型的应用程序/x-www-form-urlencoded。
是否有任何方法覆盖此行为,或者是否需要在我的spring引导应用程序中包含一个库来处理映射?我的pom.xml包括以下内容
<artifactId>oauth2-authserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>OAuth2 Auth Server</name>
<description>Authorization server for an OAuth2 controlled application</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</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-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>${spring-security-oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path-assert</artifactId>
<version>0.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<wro4j.version>1.7.6</wro4j.version>
<java.version>1.7</java.version>
<spring-security-oauth2.version>2.0.7.RELEASE</spring-security-oauth2.version>
</properties>发布于 2015-08-11 14:57:45
来自OAuth2规范
授权请求 客户端通过使用“application/x form-urlencoded”将以下参数添加到授权端点URI的查询组件来构造请求URI
和
访问令牌请求 客户端通过添加 以下参数使用"application/x-www-form-urlencoded“格式
每个请求都应该使用application/x-www-form-urlencoded。
https://stackoverflow.com/questions/31698827
复制相似问题