- OAuth 2.0 Cookbook
- Adolfo Eloy Nascimento
- 257字
- 2021-07-08 09:35:03
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:

- Python for Secret Agents:Volume II
- 樂學(xué)Web編程:網(wǎng)站制作不神秘
- 羅克韋爾ControlLogix系統(tǒng)應(yīng)用技術(shù)
- 微信公眾平臺開發(fā):從零基礎(chǔ)到ThinkPHP5高性能框架實(shí)踐
- 移動互聯(lián)網(wǎng)軟件開發(fā)實(shí)驗(yàn)指導(dǎo)
- 汽車人機(jī)交互界面整合設(shè)計(jì)
- 從零開始:UI圖標(biāo)設(shè)計(jì)與制作(第3版)
- Learning Kotlin by building Android Applications
- 寫給青少年的人工智能(Python版·微課視頻版)
- AngularJS UI Development
- Isomorphic Go
- 深入大型數(shù)據(jù)集:并行與分布化Python代碼
- Developer,Advocate!
- 深入理解Zabbix監(jiān)控系統(tǒng)
- HTML 5與CSS 3權(quán)威指南(第4版·下冊)