Token POST is not callable??
I am using Python 3.6, with Pycharm Community
I am trying to get a Token but keep getting object is not callable error?? I would appreciate any pointers to resolve this..
The error points at the line below, the error msg = TypeError: 'str' object is not callable
req = urllib.request("POST"(tokenURL, urlencode(params)))
#### For Python 3
import os, sys
import ssl
import json
import urllib
import urllib.request
from urllib.request import urlopen
from urllib.parse import urlencode
from urllib.parse import urlparse
import http.client
import requests
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': referer}
#For Python 3
req = urllib.request("POST"(tokenURL, urlencode(params)))
response = urllib.parse.urlopen(req)
try:
response = urllib.urlopen(req)
except:
gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
response = urllib.urlopen(req, context=gcontext)
data = json.load(response)
token = data['token']
print(token)
Please sign in to leave a comment.
I changed urllib.parse.urlopen to urlopen. Still get the same error??
I also tried the response option, get an OSError: Int or String expected??