2016-03-04 61 views
0

我最近打開了一個新的Instagram賬戶並註冊了一個新客戶端。我從Instagram收到的信息包括client_id和client_secret。Instagram節點調用不斷返回「訪問代碼無效」

我只會在我的機器上運行腳本,並且是項目的唯一用戶,所以我不需要任何用戶「登錄」。但由於某些原因,每當我試圖讓到Instagram的節點API的調用,它返回以下錯誤:

{ [Error: OAuthAccessTokenException: The access_token provided is invalid.] 
    code: 400, 
    error_type: 'OAuthAccessTokenException', 
    error_message: 'The access_token provided is invalid.', 
    retry: [Function] } 

這是怪我,因爲我有一箇舊的Instagram帳戶和不同的相同的設置憑據,似乎工作得很好。再次,那是在11月之前,當時Instagram改變了他們的一些API policies

我使用Instagram的節點像這樣:

ig.use({ 
    client_id: "dxxxxxxxxxxxxxxxxxxxxxxx2", 
    client_secret: "4b0xaxaxaxaxaxaxaxaxaxaxa53c03100e4" 
}); 

,讓我第一個電話是這樣的:

ig.user_media_recent(user.toString(), options,... 

我試圖通過重新路由通過REDIRECT_URI我請求處理身份驗證,如圖Instagram-Node文檔,但即使如此,我的所有請求都是未簽名的,所以我不清楚我將如何處理access_token。

任何幫助將不勝感激!

回答

0

好的,這個問題是對沙箱模式限制的誤解,它們本質上使得不可能從不在沙箱中的用戶查找媒體。

documentation here說:

The first point is important and it means that the API behaves as if the only users on Instagram were your sandbox users, and the only media ever posted were the last 20 for each of these users.

我試圖找到誰在我的沙箱中而不是用戶的媒體,所以我收到一個錯誤。之前我的憑證沒有受到影響的原因是因爲他們仍然在2016年6月的寬限期中盛行,屆時他們也將到期。謝謝!

0

我遇到了同樣的問題。如果你的應用程序使用oauth,那麼如果你再次傳遞client_secret和client_id的東西,你會導致Instagram出現問題。我不得不從我的代碼中拿出這些。所以我現在只需傳遞access_token。

ig.use({ access_token: token }); 

ig.user_media_recent(config.userid, { count: 20 }, function(err, medias, pagination, remaining, limit) { 

是我的等值語句。

編輯:我忘了提。對於那些困惑的人來說,這是一個循環:

api.authorize_user 
api.get_authorization_url