TypeError: 'dict' object is not callable

The Code
import requests
from pprint import pformat # here only for aesthetic

First we set our credentials

username = 'YOUR_USERNAME’
password = ‘YOUR_PASSWORD’

#from the developer portal
client_id = 'YOUR_CLIENT_ID’
client_secret = ‘YOUR_SECRET’

req = requests.get(‘https://apiflowerpower.parrot.com/user/v1/authenticate’,
data={‘grant_type’: ‘password’,
‘username’: username,
‘password’: password,
‘client_id’: client_id,
‘client_secret’: client_secret,
})
response = req.json()
print(‘Server response: \n {0}’.format(pformat(response)))

Get authorization token from response

access_token = response[‘access_token’]
auth_header = {‘Authorization’: ‘Bearer {token}’.format(token=access_token)}

From now on, we won’t need initial credentials: access_token and auth_header will be enough.

The Error
root@raspberrypi:~# python2 test1.py
Traceback (most recent call last):
File “test1.py”, line 20, in
response = req.json()
TypeError: ‘dict’ object is not callable

Can anybody help me?

Hello @ckerndl,
When I copy/paste your code like this:

import requests
from pprint import pformat # here only for aesthetic

username =  'YOUR_USERNAME'
password ='YOUR_PASSWORD'

client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_SECRET'

req = requests.get('https://apiflowerpower.parrot.com/user/v1/authenticate',
        data={'grant_type': 'password',
            'username': username,
            'password': password,
            'client_id': client_id,
            'client_secret': client_secret,
            })
response = req.json()
print('Server response: \n {0}'.format(pformat(response)))

access_token = response['access_token']
auth_header = {'Authorization': 'Bearer {token}'.format(token=access_token)}

I have no errors about ‘dict’.
Please, can you print req or print type(req) befor response = req.json()?