OAuth2ClientAuthenticationProcessingFilter获取令牌

问题描述 投票:0回答:1

如何从后端Java服务器获取令牌

我具有oauth服务器身份验证,可以使用Spring安全层成功登录。我通过http get请求在Web浏览器客户端中获得了代币...

https://x.x.x.x/oxauth/restv1/token

如何使用OAuth2ClientAuthenticationProcessingFilter类在后端部分获得令牌?

/**
     * Called after executed Configuration "addFilterBefore"
     *
     * @return OAuth2ClientAuthenticationProcessingFilter
     */
    private OAuth2ClientAuthenticationProcessingFilter oauthFilter() {
        OAuth2ClientAuthenticationProcessingFilter oauthFilter = new OAuth2ClientAuthenticationProcessingFilter("/login");

        // OAuth2RestTemplate > Spring Boot does not automatically create such a bean,
        OAuth2RestTemplate oauthTemplate = new OAuth2RestTemplate(oauth(), oauth2ClientContext);
        UserInfoTokenServices tokenServices = new UserInfoTokenServices(oauthResource().getUserInfoUri(), oauth().getClientId());
        tokenServices.setRestTemplate(oauthTemplate);

        oauthFilter.setRestTemplate(oauthTemplate);
        oauthFilter.setTokenServices(tokenServices);

        return oauthFilter;
    }
oauth-2.0 vaadin spring-oauth2
1个回答
0
投票

我找到了一种方法... oauthApplication.getOauth2ClientContext()。getAccessToken()

© www.soinside.com 2019 - 2024. All rights reserved.