I am learning how to use Instagram API through python-instagram package. I have clients configured, I have a client identifier and a client secret. I got the access token using the get_access_token.py script in python-instagram, but for some reason I always get this error:
Traceback (most recent call last):
File "<ipython-input-38-6440f86cbefd>", line 1, in <module>
runfile('F:/PythonProjects/minefield/instagram test.py', wdir='F:/PythonProjects/minefield')
File "C:\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 580, in runfile
execfile(filename, namespace)
File "F:/PythonProjects/minefield/instagram test.py", line 13, in <module>
api.user_search(q='samsungmobile')
File "C:\Anaconda\lib\site-packages\instagram\bind.py", line 196, in _call
return method.execute()
File "C:\Anaconda\lib\site-packages\instagram\bind.py", line 182, in execute
include_secret=self.include_secret)
File "C:\Anaconda\lib\site-packages\instagram\oauth2.py", line 224, in prepare_request
url = self._full_url_with_params(path, params, include_secret)
File "C:\Anaconda\lib\site-packages\instagram\oauth2.py", line 148, in _full_url_with_params
self._full_query_with_params(params) +
File "C:\Anaconda\lib\site-packages\instagram\oauth2.py", line 144, in _full_url
self._signed_request(path, {}, include_signed_request, include_secret))
File "C:\Anaconda\lib\site-packages\instagram\oauth2.py", line 172, in _signed_request
return "&sig=%s" % self._generate_sig(path, params, self.api.client_secret)
File "C:\Anaconda\lib\site-packages\instagram\oauth2.py", line 127, in _generate_sig
return hmac.new(secret, sig, sha256).hexdigest()
File "C:\Anaconda\lib\hmac.py", line 136, in new
return HMAC(key, msg, digestmod)
File "C:\Anaconda\lib\hmac.py", line 71, in __init__
if len(key) > blocksize:
TypeError: object of type 'NoneType' has no len()
and here is my code:
from instagram.client import InstagramAPI
access_token = '1********4.0*****5.fb1c**********39***7365*********'
api = InstagramAPI(access_token=access_token)
api.user_search(q='samsungmobile')
the script fails when calling the last line api.user_search (q = 'samsungmobile') I have no idea how this TypeError was raised, but I suspect it might have something to do with the access token.
I'm sure I'm using the right one. The get_access_token.py script returns a tuple of length 2, the first index contains the access token as a string, the second index contains a dictionary containing information about the user who has the right to use the application.