Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit ba6d269

Browse files
committed
update get_access_token to work with py2/py3
1 parent c878131 commit ba6d269

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

get_access_token.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
23
#
34
# Copyright 2007-2013 The Python-Twitter Developers
45
#
@@ -18,6 +19,11 @@
1819
from requests_oauthlib import OAuth1Session
1920
import webbrowser
2021

22+
import sys
23+
24+
if sys.version_info.major < 3:
25+
input = raw_input
26+
2127
REQUEST_TOKEN_URL = 'https://api.twitter.com/oauth/request_token'
2228
ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
2329
AUTHORIZATION_URL = 'https://api.twitter.com/oauth/authorize'
@@ -29,10 +35,7 @@ def get_access_token(consumer_key, consumer_secret):
2935

3036
print('\nRequesting temp token from Twitter...\n')
3137

32-
try:
33-
resp = oauth_client.fetch_request_token(REQUEST_TOKEN_URL)
34-
except ValueError as e:
35-
raise 'Invalid response from Twitter requesting temp token: {0}'.format(e)
38+
resp = oauth_client.fetch_request_token(REQUEST_TOKEN_URL)
3639

3740
url = oauth_client.authorization_url(AUTHORIZATION_URL)
3841

0 commit comments

Comments
 (0)