8000 Merge branch 'step-1-dev' into step-2-dev · cethap/sdk-node-tutorial@42ce9d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 42ce9d1

Browse files
committed
Merge branch 'step-1-dev' into step-2-dev
2 parents c656850 + 1934506 commit 42ce9d1

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

public/index.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3>OAuth.io server side tutorial with Node.js</h3>
3333
This tutorial helps you understand how to integrate OAuth.io to your Node.js backend.
3434
</p>
3535
<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>
3737
</div>
3838
</div>
3939
</div>
@@ -50,15 +50,12 @@ <h3>Your profile</h3>
5050
<strong>Your name :</strong> <span id="name_box">Not retrieved yet</span>
5151
</p>
5252
<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>
5754
</p>
5855
</div>
5956
<div class="col-xs-3">
6057
<a href="#" class="thumbnail">
61-
<img src="http://placehold.it/100x100" alt="...">
58+
<img id="img_box" src="http://placehold.it/100x100" alt="...">
6259
</a>
6360
</div>
6461
</div>

public/src/script.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
1-
// Here you need to put the front-end code
2-
31
function init_oauthio() {
2+
// Add the code to initialize OAuth.io here
3+
}
4+
45

6+
function retrieve_token(callback) {
7+
// Add the code to retrieve the state token here
58
}
69

7-
function register_login_button() {
10+
function authenticate(code, callback) {
11+
// Add the code to authenticate the user here
12+
}
813

14+
function retrieve_user_info(callback) {
15+
// Add the code to perform a user request here
916
}
1017

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+
});
1232

13-
}
33+
});

0 commit comments

Comments
 (0)
0