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

How it works...

This chapter presented you with how to register your application and how to connect with Facebook through the use of the Authorization Code grant type. Because it's a server side flow, it is supposed to be more secure than using the client-side approach (that is, to use the Implicit grant type). But instead of writing the code to handle all the conversations between social-authcode and Facebook (the OAuth 2.0 dance) we are using Spring Social, which provides the ConnectController class which has the capability of starting the authorization flow as well as receiving all callbacks that must be mapped when registering the application.

To better understand how this application works, run the class SocialAuthcodeApplication as Java code and go to http://localhost:8080/ to see the page that will present you with the possibility of connecting to Facebook. Click on Connect to Facebook and you will be redirected to the Facebook authentication page (as per OAuth 2.0's specifications).

After authenticating the user, Facebook presents the user consent page presenting the scope the client application is asking for. Click on continue to grant the requested permission.

After granting permission for public_profile and friend_list scopes, the user must be redirected back to localhost:8080/connect with the authorization code embedded (which will be extracted and validated by ConnectController automatically).

Note that ConnectController will render the facebookConnected view by presenting the following page:

Click on the link here so the application can retrieve the friends which have also authorized social-authcode. You are supposed to see the following page with different content:

主站蜘蛛池模板: 基隆市| 天津市| 通道| 贺兰县| 宁都县| 新和县| 盱眙县| 龙游县| 洪江市| 陇南市| 同德县| 海伦市| 洞头县| 武夷山市| 老河口市| 曲阳县| 饶阳县| 马边| 互助| 靖远县| 丰顺县| 通海县| 兴安县| 沂源县| 新乡县| 左权县| 甘孜| 八宿县| 巴中市| 宜宾市| 嵊泗县| 曲靖市| 瑞丽市| 安徽省| 仁寿县| 永新县| 太谷县| 涟源市| 拉萨市| 抚顺市| 金川县|