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

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.

主站蜘蛛池模板: 县级市| 裕民县| 南川市| 定边县| 上蔡县| 南华县| 安义县| 白河县| 唐山市| 海原县| 海丰县| 托克托县| 琼中| 河津市| 定日县| 贵港市| 江源县| 邮箱| 百色市| 新田县| 怀化市| 布尔津县| 聂荣县| 石柱| 奇台县| 天祝| 安顺市| 宣恩县| 芮城县| 鸡西市| 潜江市| 车险| 津南区| 蒙阴县| 南昌市| 闽清县| 青海省| 金华市| 鄂伦春自治旗| 开原市| 南投县|