繁体   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 ,这可能吗?

是的你可以。 当您存储客户端时,您可以为它们分配允许的授权类型(例如密码、授权代码)。

举个例子,看看他下面的代码:

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 客户端可以使用密码或授权码。

该片段来自这个指南,我强烈建议您一起跟随这一个 此外,请注意,您应该阅读OAuth2 RFC 它是了解流程的最佳指南。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM