How should I use Consumer object in oauth2 v.2 in Python 3.4?

1.2k views Asked by At

I am trying to use Yelp's API using oauth2 package (version 2), the Python 3.4 (in Anaconda's Spyder) code is like:

consumer = oauth2.Consumer(CONSUMER_KEY, CONSUMER_SECRET)

and I get this error message:

AttributeError: 'module' object has no attribute 'Consumer'

I'm guessing Consumer doesn't exist in this version of oauth2! Any help would be appreciated,

1

There are 1 answers

0
emarshah On

There is some problem with default installation of oauth2 using pip install oauth2. Right now I tried it on both Python 2.7 and Python 3.4 on Anaconda, its not working. You can copy the code ( _ _ init _ _.py) from here into your _ _ init _ _.py file and restart your kernel.

Location of your _ _ init _ _ .py file can be found via

import oauth2 as oauth
print(oauth)

After restart, kernel may ask for libraries which can be found via pip search <library_name> and then doing the pip install <library_name>