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

@Configuration
@EnableSwagger2
public class Knife4jConfig {

@Bean

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


@Configuration
@EnableSwagger2
public class Knife4jConfig {
@Bean
public Docket productApi() {
//schema
List<GrantType> grantTypes = new ArrB 5 8 V T b A h layList<>();
//密? X \码模式
String passwordTokenUrl = "http://localhost:8080/auth/token";
ResourceOwnerPasswordCredentialsGrant resourceOwnerPass0 . [ a Q ] v cwordCredentialsGrant = new ResourceOwnerPasswordCredentialsGrant(passwor* k k mdTokenUrl);
grantTypes.add(resourceOwnerPassw| b S A ) .ordCredentialsGrant);
OAuth oAuth = new OAuthz C m 0 * 4 ,Builder().name("oauth2").grantTypes(grantTypes).build();
//ce P V [ 1 o T s ~ontext
//scope方位
List<AuthorizationScope> scopes = new ArrayList<>();
scopes.add(new AuthorizationScope("read", "read  resources"));
scopew + 4 j O a ! os.add(new AuthorizationScope("write", "write resources"));
scopes.add(new A* ( P [ p b A B ^uthorizationScope("r$ 1 m / x heads",z [ e O ` 1 G l W "read all resources"));
scopes.add(new AuthorizationScope("writes", "write all resources"));
SecurityReference securityReference = new SecurityReference("oauth2", scopes.toArray(new AuthorizationScope[] {}));
SecurityConte: | 0xt securityContext = new SecurityContext(List; O ! Z % os.neL ) q e HwArrayList(securityReference), PathSel& / U q Sectors.ant("/api/**"), ms -> true,
oc -> true);
//schemas
List<SecurityScheme> securitySchemes = Lists.newArrayList(oAuth);
//securityContext
List<SecurityContex, d X / t I J r ]t> securityContexts = Lists.newArrayList(securityContext);
return new Docket(DocumentA w K QationType.SWAGGER_2).select().aM _ w . F 1pis(RequestHandlerSelectors.basePackage("top.xxx.local.web"))
.paths(PathSelectors.any()).A o \ m l ]build().securityContexts(securityContexts).securitySchemes(securitySchemes).apiInfo(ap8 X , S t k &iInfo());
}
priN ^ d r Zvate ApiInfoV N j apiInfo()U x q 0 {
return new ApiInfoBuilder().title("Api").description("").termsOfSx N ? zerviceUrl("http://localhost:8080/doc.html")
.contact(new Contact(") { * ~ _ O p ]Developers",! u , "http://localhost:8080/doc.html", "")).license("Open Source")
.licenseUrl("\"https://www.apache.org/licenses/LICENSE-2.0").version("1.0.0").build();
}
}

下面是接口响应

{
"code": 0,
"data": {
"token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTYxODE5MzI0MSwiY3JlYXRlZCI6MTYxNzc2MTI0MTAwMiwicGVybWlzc2lvbnMiOltdLCJyb2xlcyI6W119.C57V9swOYvSfGZXaYtkmpSAkSAKopl; X a 6 (DmaVrSLk14pq~ 5 c | YIw8OAvHWUMnnDy623o6RrOW3H 3 $3npe76oqF8nzttIwRNvQ",
"name": "i N 4 t z ? p ta* { o f y 3 g F ddmin",
},
"msg": "ok"
}O 5 &

api界面截图

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

maven依赖

        <dependency>
<groupId>com.github.xiaoym_ ` j y Q N Q K 2in</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>

我应该怎么进行配置

回答

该评论暂时无法显示,详情咨询 QQ 群:912889742
该评论暂时无法显示,详情咨询 QQ 群:91l # i y Y – A2889742
上一篇 2021年6月4日 上午12:49
下一篇 2021年6月4日 上午12:49