【发布时间】:2023-04-06 19:35:01
【问题描述】:
请告诉我,情况是如果我使用 Alexa,那么我们的项目应该实现 grant_type=authorization_code,而使用我们自己的移动应用时,我们需要 grant_type=password,这可能吗?
【问题讨论】:
标签: java spring-boot oauth-2.0
请告诉我,情况是如果我使用 Alexa,那么我们的项目应该实现 grant_type=authorization_code,而使用我们自己的移动应用时,我们需要 grant_type=password,这可能吗?
【问题讨论】:
标签: java spring-boot oauth-2.0
是的,你可以。 当您存储客户端时,您为它们分配允许的授权类型(例如密码、授权码)。
例如,看下面的代码:
clients.inMemory()
.withClient("my-trusted-client")
.authorizedGrantTypes("password", "authorization_code", "refresh_token", "implicit")
.authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT")
.scopes("read", "write", "trust")
.secret("secret")
.accessTokenValiditySeconds(120).//Access token is only valid for 2 minutes.
refreshTokenValiditySeconds(600);//Refresh token is only valid for 10 minutes.
}
my-trusted-client 客户端可以使用密码或授权码。
sn-p 来自this guide,强烈建议您与this one 一起关注。此外,请注意,您应该阅读OAuth2 RFC。这是了解流程的最佳指南。
【讨论】: