简体   繁体   English

我可以在 Spring Boot 中为 oauth2 在同一个项目中同时使用 grant_type=password 和 grant_type=authorization_code

[英]Can i use both grant_type=password and grant_type=authorization_code in same project for oauth2 in spring boot

请让我知道,如果我使用 Alexa,那么我们的项目应该实现grant_type=authorization_code并且在使用我们自己的移动应用程序时我们需要grant_type=password ,这可能吗?

Yes, you can.是的你可以。 When you store clients, you assign them the allowed grant type (eg password, authorization_code).当您存储客户端时,您可以为它们分配允许的授权类型(例如密码、授权代码)。

As an example, look at he following code:举个例子,看看他下面的代码:

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.
}

The my-trusted-client client can either use password or authorization code. my-trusted-client 客户端可以使用密码或授权码。

The snippet comes from this guide that I strongly suggest you to follow together with this one .该片段来自这个指南,我强烈建议您一起跟随这一个 Moreover, as a note, you should read the OAuth2 RFC .此外,请注意,您应该阅读OAuth2 RFC It is the best guide to understand the flow.它是了解流程的最佳指南。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring boot Oauth2 grant_type 密码总是返回 invalid_grant Bad Credentials - Spring boot Oauth2 grant_type password always return invalid_grant Bad Credentials 春季安全oauth2:grant_type = password身份验证 - Spring security oauth2 : grant_type=password Authentication Spring OAuth2 客户端授权类型=密码示例 - Spring OAuth2 Client grant_type=password example GET /oauth/token with grant_type=authorization_code 返回未授权 - GET /oauth/token with grant_type=authorization_code returns unauthorized 如何在 Spring Boot Oauth2 授权服务器中 grant_type=client_credentials 时抛出错误凭据的任何异常 - How to throw any Exceptions for wrong credentials when grant_type=client_credentials in Spring Boot Oauth2 Authorization Server Spring Boot 2 Spring-Security 5 OAuth2 支持 client_credentials grant_type - Spring Boot 2 Spring-Security 5 OAuth2 support for client_credentials grant_type Spring-Security-OAuth2中的grant_type - grant_type in Spring-Security-OAuth2 Spring Security oauth 2使用grant_type“ password”在TokenEndPoint上禁用客户端身份验证 - Spring Security oauth 2 Disable Client authentification on TokenEndPoint with grant_type “password” 身份验证流程中grant_type = client_credentials和grant_type = password之间的区别? - Difference between grant_type=client_credentials and grant_type=password in Authentication Flow? 请求中缺少 Grant_type - Grant_type missing in request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM