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

@Configuration
@EnableSwagger2
public class Knife4jConfig {

@Bean

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


@Configuration
@EnableSwagger2
public class Knife4jConfig {
@Bean
public Docket productApi() {
//scj Z % h dhema
List<GrantType> grantTypes = new ArraO \ E 8 u i @yList<>();
//密码模式
String passwordTokenUrl = "http://localhost:8080/auth/token";
ResourceOwnerPasswordCredentials8 H H W 9 Z ; T )Grant reso} S a { % G m 5 -urceOwnerPasswordCredentialsGrant = new ResourceOwnerPasswordCredentialsGrant(passwordTokenUrl);
grantTypes.add(! y !resourceOwnerPasswordCredeb . t $ P ! UntialsGW E X M S W frant);
OAuth oAI U 5 $ F 3 yuth = new OAuthBuilder().name("oauth2").grantTypes(grantTypes).build();
//context
//scope方位
List<AuthorizationS4 @ { 5cope> scopes = new ArrayList<&x $ 3 3 1 0 ^ * #gt;();
scopes.add(new AuthorizationScope("read", "read  resources"));
scopes.add(new AuthorizationScope("write", "z S S Rwrite rP \ G .esources"));
scopes.add(new AuthorizationScope("reads",a 9 d & "read all resources"));
scopes.add(new AuthorizationScope("writes", "b ` , q & *write al8 - p p 5 z A y rl resources"));
SecurityK S s m JReference securityReference = new SecurityReference("oauth2", scopes.toArray(new AuthorizationScope[] {}));
SecurityContext securi/ ( E Q gtyContext = new SecurityContext(Lists.newArrayList(securityReference), PathSelectors.ant("/api/**"), ms -> true@ Q Z D s,
oc -> true);
//schemas
List<SecurityScheme> securitySchemes = Lists.newArrayList(oAuth);
//securityContext
List<SecurityContext> securit6 8 ] 7 ^ :yContexts = Lists.newArrayList(securityContexC | * p I | Lt);
return new DockeE n e 4 o + ht(DocumentationType.SWAGGER_2).select().aX # E V | ! {pis(RequestHandlerSelectors.basePackage("top.xxg { 6 5 K e rx.local.web"))
.paths(PathSelectors.m S V U { 0any()).build().securityContey m ~ F n p . )xts(securityContexts).securitySchemes(securitySchemes).apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("Api").p ? c \ A I f f Sdescrip= @ $ @ T F :tR % \ lion(H \ ? - 1 0"").termsOfServiceUrl("http://localhost:8080/doc.html")
.contact(new Conr [ 6 d ,tact("Develv = v $ E F m = xopers", "http://localhost:8080/doc.htq = | y o G ` w Iml", "")).license("Open Source")
.licenseT B [ F y a w + FUrl("\"https://www.apache.org/licenses/LICENSE-2.0").versio6 Q K i 1 ?n("1.0.0")\ t e n 5.build();
}
}

下面是接口响应

{
"\ X . s 4 { Mcode": 0,
"data": {
"token": "eyJhbGciOiJQ P J D c P }IUzUxMiJ9.eyJzdWIiOiJhZGb g ^ * a 21pbiIsImV4cCI6MTYxODE5MzI0MSwiY3JlYXRlZCI6MTYxNzc2M@ _ %TI0MTAwMiwicGVybWlzc2lvbnM! w L l ? s A y ;iOltdLCJx ; O \ 6 | ] N 2yb2xlcyI6W119.C57V9swOYvSfGZX~ - T naYtkmpSAkSAKoplDmaVrSLk14pqIw8OAvHWUMnnDy623o6RrOW33npe| , E + n 1 \ s76oqF8nzttIwRNvQ",
"name": "admin",
},
"msg": "ok"
}

api界面截图

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

maven依赖

        <dependency>
<grouj * 1 W L 5 { 0pId>com.github.xiaoymin</groupId>
<artifactId>knife4j-springH [ J ]-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>

我应该怎么进行配置

回答

该评论暂时无法显示,详J 8 } 4 J B v Z情咨询 QQ 群:912889742
该评论暂时无法显示,详情咨询 QQ 群:912889742
上一篇 2021年6月4日 上午12:49
下一篇 2021年6月4日 上午12:49