instagram api keep raise'你必须提供client_id'当我使用python-instagram库

时间:2016-07-12 13:13:21

标签: python oauth-2.0 instagram-api

我在Instagram开发者信息中心注册了我的应用,并尝试使用Facebook制作的python-instagram库。

在我运行sample_app.py代码后,我访问了我的测试网站(localhost:8515)并使用我的instagram id成功登录。但是,由于此异常,我无法获取访问代码"您必须提供client_id"

我也尝试过使用这个库(https://github.com/Seraphicer/python-instagram-ext)同样的事情。这是因为他们拉出了请求的原始库并维护它。

2 个答案:

答案 0 :(得分:14)

有同样的问题,显然是因为instagram api或httplib2更新。为我固定https://github.com/vgavro/python-instagram/commit/9dfc264571ad7c343af3899445d13afedf23e3aa(链接到我的python-instagram的分支,需要补丁)

答案 1 :(得分:9)

我自己就是这样做的;无法让python-instagram工作。可能会放弃整个图书馆。我认为最近有太多的错误,而且它没有得到维护。

@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