Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

instagram api keep raise 'You must provide a client_id' exception when I use python-instagram library

I registered my app in instagram developer dashboard and tried to use python-instagram library made by Facebook.

After I ran sample_app.py code, I accessed my test website(localhost:8515) and successfully logged in using my instagram id. However, I can't get access code because of this exception "You must provide a client_id"

I also tried the same thing using this library( https://github.com/Seraphicer/python-instagram-ext) This is because they pull requested original library and maintaining it.

like image 827
flux Avatar asked Jul 12 '16 13:07

flux


2 Answers

Had the same problem, obviously due instagram api or httplib2 update. Fixed for me https://github.com/vgavro/python-instagram/commit/9dfc264571ad7c343af3899445d13afedf23e3aa (link to my fork of python-instagram with patches needed for me)

like image 60
Victor Gavro Avatar answered Nov 13 '22 13:11

Victor Gavro


I've resorted to doing it myself; couldn't get python-instagram to work. Will probably ditch the entire library. Way too many bugs lately, and it's not being maintained, I think.

@classmethod
def exchange_code_for_access_token(cls, code, redirect_uri, **kwargs):
    url = u'https://api.instagram.com/oauth/access_token'
    data = {
        u'client_id': cls.get_client_id(),
        u'client_secret': cls.get_client_secret(),
        u'code': code,
        u'grant_type': u'authorization_code',
        u'redirect_uri': redirect_uri
    }

    response = requests.post(url, data=data)

    account_data = json.loads(response.content)

    return account_data
like image 21
Peter Schaafsma Avatar answered Nov 13 '22 13:11

Peter Schaafsma