My website randomly started receiving this error. The module worked fine for quite some time, so much so that we didn't even notice it stop working.

exception 'InstagramException' with message 'BAD REQUEST' in /var/www/vhosts/stage/sites/all/modules/drupagram/drupagram.lib.php:409 Stack trace: #0 /var/www/vhosts/stage/sites/all/modules/drupagram/drupagram.lib.php(365): Instagram->request('https://api.ins...', Array, 'GET', true) #1 /var/www/vhosts/stage/sites/all/modules/drupagram/drupagram.lib.php(342): Instagram->auth_request('https://api.ins...', Array, 'GET') #2 /var/www/vhosts/stage/sites/all/modules/drupagram/drupagram.lib.php(181): Instagram->call('v1/users/!user_...', Array, 'GET', true) #3 /var/www/vhosts/stage/sites/all/modules/drupagram/drupagram.lib.php(297): Instagram->fetch('user_recent', Array, true) #4 /var/www/vhosts/stage/sites/all/modules/drupagram/drupagram.inc(174): Instagram->user_recent('436630767') #5 /var/www/vhosts/stage/sites/all/modules/drupagram/drupagram.module(168): drupagram_fetch_recent_items('436630767') #6 [internal function]: drupagram_cron() #7 /var/www/vhosts/stage/includes/module.inc(866): call_user_func_array('drupagram_cron', Array) #8 /var/www/vhosts/stage/includes/common.inc(5321): module_invoke('drupagram', 'cron') #9 /var/www/vhosts/stage/modules/system/system.admin.inc(2356): drupal_cron_run() #10 [internal function]: system_run_cron() #11 /var/www/vhosts/stage/includes/menu.inc(517): call_user_func_array('system_run_cron', Array) #12 /var/www/vhosts/stage/index.php(21): menu_execute_active_handler() #13 {main}

I've updated the API keys and everything seems right. Any ideas?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skribbz14’s picture

I was able to fix this, but uninstalling, installing the dev version, re-entering the api keys, and connecting the account to the user one more time.

DamienMcKenna’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

Sounds like this may be fixed in the current -dev release?

eg2234’s picture

I'm getting this error too, and updating to 7.x-1.2+14-dev isn't solving the issue.

vhin0210’s picture

FileSize
2.54 KB

@eg2234,

I also have this issue and I believe that it's because of instagram new api.

I created a patch for 7.x-1.2

jack.minster’s picture

I applied the patch in #2484333-4: exception 'InstagramException' with message 'BAD REQUEST', but was still getting a BAD REQUEST exception. Looking at the response it indicated I had a bad access token (OAuthAccessTokenException , "The access_token provided is invalid."). Removing the instagram account through the Drupagram user page and re-adding/auth'ing with instagram appears to have worked.

vhin0210’s picture

@jack.minster

have you tried authenticating your user again? like delete the current connected user and connect again?

Finabluma’s picture

Same problem here. I have applied the patch and also remove the account and still happens...

vhin0210’s picture

May i know which api are you trying to access?

mgpcreative’s picture

Is it possible that the issue is related to the fact that we need to be using OAuth 2.0 protocol according to https://www.instagram.com/developer/authentication/ instead of 1.0 that is currently used in the module?

Daniel Korte’s picture

Daniel Korte’s picture

Whoops, didn't pick up the Related Issue I was trying to add... Here we go...

Daniel Korte’s picture

I created a different patch that addresses the original issue. It appears to be that the correct headers are not sent. See here:
https://groups.google.com/forum/#!topic/instagram-api-developers/Dvu_4SX...

I was able to get things working with this patch which sets the correct request headers for the get_access_token() function.

Daniel Korte’s picture

Status: Postponed (maintainer needs more info) » Needs review
b_willems’s picture

FYI I applied the patch in https://www.drupal.org/node/2484333#comment-11281155, deleted the old account under /user/.../edit/drupagram, cleared cache, added the account back in and ran cron and it worked. No errors and images are back. Thx mucho for the patch!

mihaic’s picture

recently had Invalid Instagram OAuth request: Token invalid
#12 worked for me very well
thanks for patch

  • Daniel Korte committed 093be63 on 7.x-1.x
    Issue #2484333 by Daniel Korte: exception 'InstagramException' with...
Daniel Korte’s picture

Status: Needs review » Fixed

I applied this patch to latest dev branch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jftzsmns’s picture

Found this thread through: https://www.drupal.org/node/2762823

I applied this patch to the latest stable release and can confirm it fixes the issue.