Currently when trying to login with botpassword, a warning message indicating "fetching a token via "action=login" is deprecated" will be shown, and an error message will be returned. The logic inside `login_to_site` function is to [[ https://github.com/wikimedia/pywikibot/blob/f9d33837b7a9751da8627707705252e4ff6f6046/pywikibot/data/api.py#L2979 | submit a login request (w/o "lgtoken" parameter) first ]], then perform a re-login. I thought probably we could move the code block of getting a login token to the position before submit a login request (inside that while True loop), which could fix such warning.
```
>>> import pywikibot
>>> site = pywikibot.Site('test', 'wikipedia', user='Crystal-bot')
>>> site.login()
WARNING: No user is logged in on site wikipedia:zh
Logging in to wikipedia:test as Crystal-bot@signbot1
WARNING: API warning (main): Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes. Use [[Special:ApiFeatureUsage]] to see usage of deprecated features by your application.
WARNING: API warning (login): Fetching a token via "action=login" is deprecated. Use "action=query&meta=tokens&type=login" instead.
ERROR: Received incorrect login token. Forcing re-login.
>>>
```