s = api.update_status('test %i' % random.randint(0, 1000))
api.destroy_status(s.id)
+ def testaccesstype(self):
+ auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
+ auth_url = auth.get_authorization_url(access_type='read')
+ print('Please open: ' + auth_url)
+ answer = raw_input('Did Twitter only request read permissions? (y/n) ')
+ self.assertEqual('y', answer.lower())
def apply_auth(self):
return OAuth1(self.consumer_key, client_secret=self.consumer_secret, resource_owner_key=self.access_token, resource_owner_secret=self.access_token_secret)
- def _get_request_token(self):
+ def _get_request_token(self, access_type = None):
try:
url = self._get_oauth_url('request_token')
+ if access_type:
+ url += '?x_auth_access_type=%s' % access_type
return self.oauth.fetch_request_token(url)
except Exception as e:
raise TweepError(e)
self.access_token = key
self.access_token_secret = secret
- def get_authorization_url(self, signin_with_twitter = False):
+ def get_authorization_url(self, signin_with_twitter = False, access_type = None):
"""Get the authorization URL to redirect the user"""
try:
if signin_with_twitter:
url = self._get_oauth_url('authenticate')
else:
url = self._get_oauth_url('authorize')
- self.request_token = self._get_request_token()
+ self.request_token = self._get_request_token(access_type=access_type)
return self.oauth.authorization_url(url)
except Exception as e:
raise TweepError(e)