Search code examples
pythonoauth-2.0instagram-api

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.


Solution

  • 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