官术网_书友最值得收藏!

There's more...

For this recipe, we didn't create any configuration class. But if you want to define the base URL for callback redirection that happens when using the OAuth 2.0 protocol, you need to create a configuration class to define a custom ConnectController bean, as presented in the following code:

@Configuration 
public class LinkedInConfiguration { 
    @Bean 
    public ConnectController connectController(ConnectionFactoryLocator locator, 
        ConnectionRepository repository) { 
        ConnectController controller = new ConnectController(locator, repository); 
        controller.setApplicationUrl("http://localhost:8080"); 
        return controller; 
    } 
} 

By doing such configurations, you avoid issues when the application runs behind a proxy. The redirect URI will be automatically generated using the request info which will be based on the application which might be running behind a proxy. This way, the OAuth 2.0 Provider won't be able to redirect to the right callback URL because it will be hidden by the proxy. The configuration presented previously allows you to define the proxy's URL.

Do not forget to define the same redirect URL at the OAuth 2.0 Provider and make all the communication through TLS/SSL.

主站蜘蛛池模板: 屯留县| 图们市| 宜阳县| 新竹市| 定结县| 项城市| 松阳县| 英超| 哈巴河县| 磐石市| 白河县| 浦城县| 青铜峡市| 黄石市| 太谷县| 宜州市| 贵德县| 永兴县| 灵山县| 读书| 镇巴县| 泰和县| 大姚县| 中阳县| 清丰县| 天津市| 孟州市| 奉节县| 台南县| 荆门市| 南投市| 青州市| 胶州市| 丹棱县| 襄汾县| 荥阳市| 连平县| 昆明市| 丽江市| 台湾省| 西吉县|