File: oauth_test_2.py

package info (click to toggle)
python-flickrapi 2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 468 kB
  • sloc: python: 2,145; makefile: 147; sh: 10
file content (37 lines) | stat: -rwxr-xr-x 1,119 bytes parent folder | download
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))