def _oauth_login(site) -> None: consumer_key, consumer_secret = _get_consumer_token(site) login_manager = OauthLoginManager(consumer_secret, site, consumer_key) login_manager.login() identity = login_manager.identity if identity is None: pywikibot.error('Invalid OAuth info for {site}.'.format(site=site)) elif site.username() != identity['username']: pywikibot.error( 'Logged in on {site} via OAuth as {wrong}, but expect as {right}'. format(site=site, wrong=identity['username'], right=site.username())) else: oauth_token = login_manager.consumer_token + login_manager.access_token pywikibot.output('Logged in on {site} as {username}' 'via OAuth consumer {consumer}\n' 'NOTE: To use OAuth, you need to copy the ' 'following line to your user-config.py:\n' 'authenticate[{hostname!r}] = {oauth_token}'.format( site=site, username=site.username(), consumer=consumer_key, hostname=site.hostname(), oauth_token=oauth_token))
def _oauth_login(site) -> None: consumer_key, consumer_secret = _get_consumer_token(site) login_manager = OauthLoginManager(consumer_secret, site, consumer_key) login_manager.login() identity = login_manager.identity if identity is None: pywikibot.error('Invalid OAuth info for %(site)s.' % {'site': site}) elif site.username() != identity['username']: pywikibot.error('Logged in on %(site)s via OAuth as %(wrong)s, ' 'but expect as %(right)s' % {'site': site, 'wrong': identity['username'], 'right': site.username()}) else: oauth_token = login_manager.consumer_token + login_manager.access_token pywikibot.output('Logged in on %(site)s as %(username)s' 'via OAuth consumer %(consumer)s' % {'site': site, 'username': site.username(), 'consumer': consumer_key}) pywikibot.output('NOTE: To use OAuth, you need to copy the ' 'following line to your user-config.py:') pywikibot.output("authenticate['%(hostname)s'] = %(oauth_token)s" % {'hostname': site.hostname(), 'oauth_token': oauth_token})
def _oauth_login(site): consumer_key, consumer_secret = _get_consumer_token(site) login_manager = OauthLoginManager(consumer_secret, False, site, consumer_key) login_manager.login() identity = login_manager.identity if identity is None: pywikibot.error('Invalid OAuth info for %(site)s.' % {'site': site}) elif site.username() != identity['username']: pywikibot.error('Logged in on %(site)s via OAuth as %(wrong)s, ' 'but expect as %(right)s' % {'site': site, 'wrong': identity['username'], 'right': site.username()}) else: oauth_token = login_manager.consumer_token + login_manager.access_token pywikibot.output('Logged in on %(site)s as %(username)s' 'via OAuth consumer %(consumer)s' % {'site': site, 'username': site.username(sysop=False), 'consumer': consumer_key}) pywikibot.output('NOTE: To use OAuth, you need to copy the ' 'following line to your user-config.py:') pywikibot.output('authenticate[\'%(hostname)s\'] = %(oauth_token)s' % {'hostname': site.hostname(), 'oauth_token': oauth_token})
def _get_login_manager(self): login_manager = OauthLoginManager(password=self.consumer_token[1], site=self.site, user=self.consumer_token[0]) # Set access token directly, discard user interaction token fetching login_manager._access_token = self.access_token return login_manager
def _get_login_manager(self): login_manager = OauthLoginManager(self.consumer_token[1], False, self.site, self.consumer_token[0]) # Set access token directly, discard user interaction token fetching login_manager._access_token = self.access_token return login_manager