forked from sybrenstuvel/flickrapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oauth_test_2.py
executable file
·37 lines (27 loc) · 1.09 KB
/
oauth_test_2.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
#!/usr/bin/env python
import logging
logging.basicConfig(level=logging.DEBUG)
from flickrapi import auth
class keys:
apikey = u'a233c66549c9fb5e40a68c1ae156b370'
apisecret = u'03fbb3ea705fe096'
print('Creating OAuth interface')
flickr_oauth = auth.OAuthFlickrInterface(keys.apikey, keys.apisecret)
# ------------------------------------------------------------------------------
print('Step 1: obtain a request token')
flickr_oauth.get_request_token()
# ------------------------------------------------------------------------------
print('Step 2: let the user authenticate the token')
flickr_oauth.auth_via_browser('read')
# ------------------------------------------------------------------------------
print('Step 3: exchange for an access token')
flickr_oauth.get_access_token()
# ------------------------------------------------------------------------------
print('Step 4: use Flickr!')
params = {
'method': 'flickr.photos.getInfo',
'format': 'json',
'nojsoncallback': 1,
'photo_id': '7658567128',
}
print(flickr_oauth.do_request('http://api.flickr.com/services/rest/', params))