File tree Expand file tree Collapse file tree 2 files changed +28
-11
lines changed Expand file tree Collapse file tree 2 files changed +28
-11
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ <h3>OAuth.io server side tutorial with Node.js</h3>
33
33
This tutorial helps you understand how to integrate OAuth.io to your Node.js backend.
34
34
</ p >
35
35
< div >
36
- < button class ="btn btn-primary " id ="login_button "> Login through Facebook </ button >
36
+ < button class ="btn btn-primary " id ="login_button "> Login</ button >
37
37
</ div >
38
38
</ div >
39
39
</ div >
@@ -50,15 +50,12 @@ <h3>Your profile</h3>
50
50
< strong > Your name :</ strong > < span id ="name_box "> Not retrieved yet</ span >
51
51
</ p >
52
52
< p >
53
- < strong > Your email :</ strong > < span id ="name_box "> Not retrieved yet</ span >
54
- </ p >
55
- < p >
56
- < strong > Your birthday :</ strong > < span id ="name_box "> Not retrieved yet</ span >
53
+ < strong > Your email :</ strong > < span id ="email_box "> Not retrieved yet</ span >
57
54
</ p >
58
55
</ div >
59
56
< div class ="col-xs-3 ">
60
57
< a href ="# " class ="thumbnail ">
61
- < img src ="http://placehold.it/100x100 " alt ="... ">
58
+ < img id =" img_box " src ="http://placehold.it/100x100 " alt ="... ">
62
59
</ a >
63
60
</ div >
64
61
</ div >
Original file line number Diff line number Diff line change 1
- // Here you need to put the front-end code
2
-
3
1
function init_oauthio ( ) {
2
+ // Add the code to initialize OAuth.io here
3
+ }
4
+
4
5
6
+ function retrieve_token ( callback ) {
7
+ // Add the code to retrieve the state token here
5
8
}
6
9
7
- function register_login_button ( ) {
10
+ function authenticate ( code , callback ) {
11
+ // Add the code to authenticate the user here
12
+ }
8
13
14
+ function retrieve_user_info ( callback ) {
15
+ // Add the code to perform a user request here
9
16
}
10
17
11
- function retrieve_user_info ( ) {
18
+
19
+ $ ( '#login_button' ) . click ( function ( ) {
20
+ init_oauthio ( ) ;
21
+ retrieve_token ( function ( err , code ) {
22
+ authenticate ( code , function ( err ) {
23
+ if ( ! err ) {
24
+ retrieve_user_info ( function ( user_data ) {
25
+ $ ( '#name_box' ) . html ( user_data . name )
26
+ $ ( '#email_box' ) . html ( user_data . email ) ;
27
+ $ ( '#img_box' ) . attr ( 'src' , user_data . avatar ) ;
28
+ } ) ;
29
+ }
30
+ } ) ;
31
+ } ) ;
12
32
13
- }
33
+ } ) ;
You can’t perform that action at this time.
0 commit comments