Пример #1
0
    def get_authorization_data(self):
        oauth = requests_oauthlib.OAuth1Session(get_oauth_client('https://api.twitter.com'), get_oauth_secret('https://api.twitter.com'))
        fetch_response = oauth.fetch_request_token('https://api.twitter.com/oauth/request_token')
        auth_url = oauth.authorization_url('https://api.twitter.com/oauth/authorize')

        return (auth_url,
                fetch_response.get('oauth_token'),
                fetch_response.get('oauth_token_secret'),
        )
Пример #2
0
    def authorize(self, ownerkey, ownersecret, pincode):
        oauth = requests_oauthlib.OAuth1Session(get_oauth_client('https://api.twitter.com'),
                                                get_oauth_secret('https://api.twitter.com'),
                                                resource_owner_key=ownerkey,
                                                resource_owner_secret=ownersecret,
                                                verifier=pincode)
        tokens = oauth.fetch_access_token('https://api.twitter.com/oauth/access_token')

        return tokens
Пример #3
0
 def tw(self):
     if not self._tw and 'token' in self.providerconfig:
         self._tw = requests_oauthlib.OAuth1Session(
             get_oauth_client('https://api.twitter.com'),
             get_oauth_secret('https://api.twitter.com'),
             self.providerconfig['token'],
             self.providerconfig['secret'],
         )
     return self._tw
Пример #4
0
 def _get_oauth_session(self):
     return requests_oauthlib.OAuth2Session(
         get_oauth_client(self.instance.config['baseurl']),
         redirect_uri='urn:ietf:wg:oauth:2.0:oob',
         scope=MASTODON_SCOPES)