Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted files for clarity and improved readability #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions Lesson4/step2/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,11 @@ def fbconnect():
app_id, app_secret, access_token)
h = httplib2.Http()
result = h.request(url, 'GET')[1]
# process the result into a python array using json.loads
result_array = json.loads(result)


# Use token to get user info from API
userinfo_url = "https://graph.facebook.com/v2.8/me"
'''
Due to the formatting for the result from the server token exchange we have to
split the token first on commas and select the first index which gives us the key : value
for the server access token then we split it on colons to pull out the actual token value
and replace the remaining quotes with nothing so that it can be used directly in the graph
api calls
'''
token = result.split(',')[0].split(':')[1].replace('"', '')
# select the access_token from the processed array
token = result_array['access_token']

url = 'https://graph.facebook.com/v2.8/me?access_token=%s&fields=name,id,email' % token
h = httplib2.Http()
Expand Down
11 changes: 2 additions & 9 deletions Lesson4/step2/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,10 @@
}
</script>


<button>


<fb:login-button scope="public_profile,email" onlogin="sendTokenToServer();">
<a href='javascript:sendTokenToServer()'>Login with Facebook</a>

<fb:login-button scope="public_profile,email" onlogin="sendTokenToServer();">
<a href='javascript:sendTokenToServer()'>Login with Facebook</a>
</fb:login-button>


</button>
<!--END FACEBOOK SIGN IN -->

</body>
Expand Down