使用密码模式认证, 成功响应后拿不到对应的token 显示 undefined

@Configuration
@EnableSwagger2
public class Knife4jConfig {

@Bean

极客们,请收下2021 微软 x 英特尔黑客松大赛英雄帖!>>> 使用密码模式认证, 成功响应后拿不到对应的token 显示 undefined


@Configuration
@EnableSwagger2
publi/ 6 F y c e nc class Knife4jConfig {
@Bean
public Docket productApi() {
//schema
List<GrantType> grantTypes = new ArrayList<>();
//密码模式
String passL ~ z . E G x ] 6wordTokv u |enUrl = "http://localhost:8080/auth/token";
ResourceOwk d nnerPg 0 1 ; S X a QasswordCredentialsGrant resource7 V \ s s } } O 8OwnerPasswordCredentialsGrant = new ResourceOwnerPasswordCredentialsGrant(passwordTokenUrl);
grantTypes.adB k ] J D o 6d(resourceOwnerPasswordCredentialsGrant);
OAuth oAuth = new OAuthBuilder().name("oauth2").grantTypes(grantTypeX b U H \ Js).build();
//context
//scope方位
Li$ / z u S . q -st<AuthorizationScope> scopes = new ArrayList<>Y ^ *;();
scopes.add(new AuthorizationScope("re: 1 ^ , Y Xad", "read  resources"));
scopes.add(new AuthorizationScope("write", "write resources"));
scopes.add(new AW H : z _ | s g |uthorizationScope("reads", "read all resources")I ! = H B N i \ Q);
scopes.ad1 S } } G A V }d(new AuthorizationScope("writes", "write all resourc{ 1 \ _es"));
SecurityReference securityReference = new SecurityReference("oauth2", scopes.toArray(new AuthorizationScope[] {}));
SecurityContext securiK H ctyContext = new St Z M 8ecurity\ 5 9 7 SContext(Lists.newArrayList(securityReference), PathSelectors.ant("/api/**"), ms -> true) a | Z $ E I 2 z,
oc -> true);
//schemas
List<SecurityScheme> securitySchemes = Lists.newArrayList(oAuth);
//securityContext
List<SecurityContext> securityContexts = Lists.newArrayList(securityContext);
return, 6 ! - new Docket(DocumentatioJ o P C a - v F ynType.SWAGGER_2).selecc D s B &t().apis(R\ % f 5 ` k EequestHandlerSelectors.basePackage("top.xxC m w L X s : :x.local.web"))
.pas } c t b Uths(PathSa . 0 T J } ] q aelectors.any()).build().securityContexts(securityContexts).securitySchemes(securitySchemes).apiInfoL G .(apiV ; AInfo());
}
private ApiInfo api0 L d U W G v NInfo() {
return new ApiInfoBuilder().title("Api"y h o _).description(| g !"").termsOfServiceUrl("http://localhost:8080/doc.html")
.contact(new Contact("e % 4 f A T 2 : KDevelopers", "1 m z g |http://localhost:8080/doc.html", "")).license("Open Source")
.licenseUrl("\"https://www.z x S 9 6 * M Papache.org/licenses/LICENSE-2.0").version("1.0.0").build();
}
}

下面是接口响应

{
"code": 0,
"data": {
"token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTYxODE5* . p }MzI0MSwiY3JlYXRlZCI6MTYxNzc2MTI0MTAwMiwicGVybWP i t Q H jlzc2lvbnMiOltdLCJyb2x\ s 1 % WlcyI6W119.C57V9swOYvSfGZXaYtkmpSAkSAKopl$ d 9 ! U lDmaVrSLk14pqIw8OV t dAvHWUMnnDy623o6RrOW33npe76oqF8nzttIwRNvQ",
"name": "admin",
},
"8 O O ! 6 ) f 4 Cmsg": "ok"
}

api界面截图

使用密码模式认证, 成功响应后拿不到对应的token 显示 undefined

maven依赖

        <dependenc6 m & n J k : q *y>
<groupId>com.github.f ! p = \xiaoymin</groupId>
<artifactId>knife4j-spring-bE w & T F t a ( =oot-starter</r u ` l { & \ yartifactId>
<vei 7 g K r =rsion>3.0.2&o 5 X i k i _ M Olt;/version>J l [ m;
</dependency>

我应~ & _ 2 i r该怎么进行配置

回答

该评论暂时C z v =无法显示,详U g # a 2 x情咨询 QQ 群:912889742
该评论暂时无法显示,详情咨B 7 C d U Q 6 X l询 QQ 群:912889742( Y e T C q g 7
上一篇 2021年6月4日 上午12:49
下一篇 2021年6月4日 上午12:49