-
Notifications
You must be signed in to change notification settings - Fork 490
/
Copy pathfacebook__login.py
98 lines (81 loc) · 2.77 KB
/
facebook__login.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- coding: utf-8 -*-
import os
import sys
import webbrowser
import urllib
def login():
# Get this value from your Facebook application's settings
CLIENT_ID = ''
REDIRECT_URI = 'http://miningthesocialweb.appspot.com/static/facebook_oauth_helper.html'
# You could customize which extended permissions are being requested on the login
# page or by editing the list below. By default, all the ones that make sense for
# read access as described on http://developers.facebook.com/docs/authentication/
# are included. (And yes, it would be probably be ridiculous to request this much
# access if you wanted to launch a successful production application.)
EXTENDED_PERMS = [
'user_about_me',
'friends_about_me',
'user_activities',
'friends_activities',
'user_birthday',
'friends_birthday',
'user_education_history',
'friends_education_history',
'user_events',
'friends_events',
'user_groups',
'friends_groups',
'user_hometown',
'friends_hometown',
'user_interests',
'friends_interests',
'user_likes',
'friends_likes',
'user_location',
'friends_location',
'user_notes',
'friends_notes',
'user_online_presence',
'friends_online_presence',
'user_photo_video_tags',
'friends_photo_video_tags',
'user_photos',
'friends_photos',
'user_relationships',
'friends_relationships',
'user_religion_politics',
'friends_religion_politics',
'user_status',
'friends_status',
'user_videos',
'friends_videos',
'user_website',
'friends_website',
'user_work_history',
'friends_work_history',
'email',
'read_friendlists',
'read_requests',
'read_stream',
'user_checkins',
'friends_checkins',
]
args = dict(client_id=CLIENT_ID, redirect_uri=REDIRECT_URI,
scope=','.join(EXTENDED_PERMS), type='user_agent', display='popup'
)
webbrowser.open('https://graph.facebook.com/oauth/authorize?'
+ urllib.urlencode(args))
# Optionally, store your access token locally for convenient use as opposed
# to passing it as a command line parameter into scripts...
access_token = raw_input('Enter your access_token: ')
if not os.path.isdir('out'):
os.mkdir('out')
filename = os.path.join('out', 'facebook.access_token')
f = open(filename, 'w')
f.write(access_token)
f.close()
print >> sys.stderr, \
"Access token stored to local file: 'out/facebook.access_token'"
return access_token
if __name__ == '__main__':
login()