import sys
import urllib

# parse_qsl moved to urlparse module in v2.6
try:
  from urlparse import parse_qsl
except:
  from cgi import parse_qsl

import oauth2 as oauth
from oauth_keys import SERVICE_PROVIDERS

if len(sys.argv) != 2:
    print 'Usage: python get_oauth_access_token.py [%s]' % (
        '|'.join(SERVICE_PROVIDERS.keys()))
    exit(1)

service_provider = SERVICE_PROVIDERS.get(sys.argv[1])

oauth_client = oauth.Client(service_provider.consumer)

print 'Requesting temp token'

request_token_body = urllib.urlencode({'oauth_callback': 'oob'})
resp, content = oauth_client.request(
    service_provider.request_token_url, 'POST', body=request_token_body)

if resp['status'] != '200':
  print 'Invalid response requesting temp token: %s\n%s' % (
      resp['status'], content)
import sys

from oauth_keys import SERVICE_PROVIDERS

if len(sys.argv) != 2:
    print "Usage: python get_oauth_access_token.py [%s]" % ("|".join(SERVICE_PROVIDERS.keys()))
    exit(1)

service_provider = SERVICE_PROVIDERS[sys.argv[1]]
for i in xrange(0, len(service_provider.access_tokens)):
    oauth_client = service_provider.get_oauth_client(token_index=i)
    resp, content = oauth_client.request(service_provider.test_url, "GET")
    print "Token %d" % i
    print "    Response: %s" % str(resp)
    print "    Content: %s" % str(content)
Example #3
0
import sys
import urllib

# parse_qsl moved to urlparse module in v2.6
try:
    from urlparse import parse_qsl
except:
    from cgi import parse_qsl

import oauth2 as oauth
from oauth_keys import SERVICE_PROVIDERS

if len(sys.argv) != 2:
    print 'Usage: python get_oauth_access_token.py [%s]' % ('|'.join(
        SERVICE_PROVIDERS.keys()))
    exit(1)

service_provider = SERVICE_PROVIDERS.get(sys.argv[1])

oauth_client = oauth.Client(service_provider.consumer)

print 'Requesting temp token'

request_token_body = urllib.urlencode({'oauth_callback': 'oob'})
resp, content = oauth_client.request(service_provider.request_token_url,
                                     'POST',
                                     body=request_token_body)

if resp['status'] != '200':
    print 'Invalid response requesting temp token: %s\n%s' % (resp['status'],
import sys

from oauth_keys import SERVICE_PROVIDERS

if len(sys.argv) != 2:
    print 'Usage: python get_oauth_access_token.py [%s]' % (
        '|'.join(SERVICE_PROVIDERS.keys()))
    exit(1)

service_provider = SERVICE_PROVIDERS[sys.argv[1]]
for i in xrange(0, len(service_provider.access_tokens)):
    oauth_client = service_provider.get_oauth_client(token_index=i)
    resp, content = oauth_client.request(service_provider.test_url, 'GET')
    print 'Token %d' % i
    print '    Response: %s' % str(resp)
    print '    Content: %s' % str(content)