'Authorisation Error while trying to use Reddit Api

I am trying to connect with Reddit API to get data for analysis, but am meeting a roadblock of not being able to retrieve the "access_token". Below is the code I have written, I really need the solution to this problem, below is the code

client_id = 'r7L-BcPLzoXkPl4*****'

secret = 'E1uNURdvTwu6kT09ertNNqo5*****'

import requests

auth = requests.auth.HTTPBasicAuth(client_id, secret)

with open('password.txt', 'r') as fp:
    pwd = fp.read()

data = {'grant_type': 'password',
        'username': 'josehope',
        'password': pwd}

headers = {'User-Agent': 'Hitan/0.0.1'}

res = requests.post('https://www.reddit.com/api/v1/access_token',
                    auth=auth, data=data, headers=headers)

res
output ---> <Response [200]>

token = res.json()["access_token"]

This is the error I get after running the above code

KeyError                                  Traceback (most recent call last)
<ipython-input-18-e2a3bbd5aa7e> in <module>
----> 1 token = res.json()["access_token"]

KeyError: 'access_token'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source