code: def initiate(mw_uri, consumer_token, callback='oob',
               user_agent=defaults.USER_AGENT):
      
      auth = OAuth1(consumer_token.key,
                    client_secret=consumer_token.secret,
                    callback_uri=callback)
  
      r = requests.post(url=mw_uri,
                        params={'title': "Special:OAuth/initiate"},
                        auth=auth,
                        headers={'User-Agent': user_agent})
  
      credentials = parse_qs(r.content)
  
      if credentials is None or credentials == {}:
          raise OAuthException(
              "Expected x-www-form-urlencoded response from " +
              "MediaWiki, but got something else: " +
              "{0}".format(repr(r.content)))
  
      elif b('oauth_token') not in credentials or \
           b('oauth_token_secret') not in credentials:
  
          raise OAuthException(
              "MediaWiki response lacks token information: "
              "{0}".format(repr(credentials)))
  
      else:
  
          request_token = RequestToken(
              credentials.get(b('oauth_token'))[0],
              credentials.get(b('oauth_token_secret'))[0]
          )
  
      params = {'title': "Special:OAuth/authenticate",
                'oauth_token': request_token.key,
                'oauth_consumer_key': consumer_token.key}
  
      return (
          mw_uri + "?" + urlencode(params),
          request_token
      )
docs: Initiate an oauth handshake with MediaWiki.
  
      :Parameters:
          mw_uri : `str`
              The base URI of the MediaWiki installation.  Note that the URI
              should end in ``"index.php"``.
          consumer_token : :class:`~mwoauth.ConsumerToken`
              A token representing you, the consumer.  Provided by MediaWiki via
              ``Special:OAuthConsumerRegistration``.
          callback : `str`
              Callback URL. Defaults to 'oob'.
  
      :Returns:
          A `tuple` of two values:
  
          * a MediaWiki URL to direct the user to
          * a :class:`~mwoauth.RequestToken` representing a request for access