**Steps to replicate the issue** (include links if applicable):
* Use a private wiki
* Configure a families file, user-config, and user-password file
* Use pwb login
**What happens?**:
This command will fail with a readapidenied error.
**What should have happened instead?**:
The login should have succeeded
**Software version** (skip for WMF-hosted wikis like Wikipedia):
Python 3.11.1, pywikibot 8.0.0, MediaWiki 1.37.4
**Other information** (browser name/version, screenshots, etc.):
Python 3.11.1, pywikibot 8.0.0
The correction is found in login.py around line 430:
```lang=python
login_request[
self. Keyword('token')] = self.site.tokens['login']
```
should be changed to:
```lang=python
login_request[
self. Keyword('token')] = response['token']
```
Making this change allowed the login process to continue. The problem is that self.site.token is an empty dict at this point in the login process. The response has the needed token.