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

@Configuration
@EnableSwagger2
public class Knife4jConfig {

@Bean

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


@Configuration
@EnableSwagger2
public class Knife4jConfig {
@Be} $ X _ ; _an
public Docket productApiC C a f N y _ h() {
//schema
List<GrantType> g2 N ; Y q - x XrantTypeZ & t x &s = new ArrayList<>();
//密v Q K a X a z Q h码模式
String pa\ 6 L DsswordTokenUrl = "httpu h . _ J ! / y://localhost:8080/auth/token";
ResourceOwA : [ Z 7 0 $ `nerPasswordCredentialsGrant resourceOwnerPasswordCredentialsGrant = new ResourceOwne2 V / + 0 Z \ 1 QrPasswordCredentialsGrant(passwordTokenUrl);
grantTypes.add(resourceOwnerPasswordCredentialsGrant);
OAuth oAN $ v Y auth = new OAuthBuilder().name("oauth2").grantTypes(grantTypes).buildx ~ N o ! @();
//context
//scope方位
List<AuthorizationScope> scopes = new ArrayList<>();
scopes.a4 Z ~dd(new AuthorizationScope("read", "readX } M ( C : _ F t  resources"));
scm . ` ; kopes.add(new Autho/ y i J 0 p \ 7 XrizationScope("writex % u G m", "write resources"));
scopes.add(new AC v cuthorizationScope("reads", "read all resources"));
scopes.add(new AuthorizationScope("writes", "write all resources"));
SecurityReference securityReferenh N 1 O Rce = new SecurityR. ? J Q 0 Weference("oauth2", scopes.toArray(new AuthorizationScope[] {}));
SecurityConteE N Wxt securityContext = new SecurityContext(Lists.newAX e ` | n |rrayList(securityReference), PathSelectors.ant("/api/**"), ms -> true,
oc -> true);
//schemas
List<O Q t , ^SecurityScheme> securitySchemO 9 l { B o 5 .es = Lists.newArrayLiX A P o : I 3st(oAuth);
//securityContext
List<SecurityContext> securityCoT 4 z / ~ W ontexts = Lists.newArrayList(securityContext);
return new Docke5 O ]t(DocumentationType.SWAGGER_2).select().apis(Reque[ N R v 2 U 2stHandlerSelectors.basePackage("top.xxx.local.web"\ h b *))
.paths(PathSelectorK 1 M * 5s.any()).build().securityContextL o 9 3s(securityContexts).secu_ } [ o - ` 5ritySchemes(securitySchemes).apiInfo(apiInfo());
}
private ApiInfo apij , y O X y .Info() {
return new ApiInfoBuilder().title("Api").t : ; edescription("")O B ] [ C c r.termsOfServiceUrl("http://localhost:8080/doc.html")
.contact(new Contact("Developers", "http://localhost:8080/doc.html", "")).license("Open Source")
.licenseUrl("\"C L + n * @ hhttps://www./ t \apacheb z m ! N f i , q.org/licenses/LICENSE-2.0").version("1.0.0").build();
}
}

下面是接口响应

{
"? G t t 9 3code": 0,
"data": {
"token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTYxODEI i 9 Z5MzI0MSwiY3JlYXRlZCI6Mr q ? *TYxNzc2MTI0MTAwMiwicGVybWl+ L $ X Q }zc2lvbnMiOltdLCJyb2xlcyI6W119.C57V9swOYvSfGZXaYtkmpSAkSAKoplDmaVrSLk14pqIw8Ov o a H l 1 h + mAvHWUMnnDy623o6RrOW33npe76oqF8nzttIwRNvQ",
"name": "admin",
},
"msg": "ok"
}

api界面截图

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

mav( @ =en依赖

        <dependency>
<groupId>com.github.xiaU , x } Poymin<~ ` 4 } u (/groupId>
<artifactIdX T 8 C 7 o . ^>knife4j-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>

我应该怎么进行配置

回答

该评论暂时无法显示,详情咨询 QQ 群:9) Q i # }12889742
该评论暂时无法显示,详情咨询 QQ 群:912889742
上一篇 2021年6月4日 上午12:49
下一篇 2021年6月4日 上午12:49