PHP OAuth Uncaught exception 'OAuthException'

I'm trying to connect to this system's API: http://api.figshare.com/docs/intro.html

The initial dus toff is okay, the user is presented with a login screen and asked to confirm they want to grant access, after they are pushed back to a callback handler

function callback($args, &$request) {
		$article_id = clean_string(array_shift($args));
		$this->validate($request, $article_id, 4);

		$consumer_key = Config::getVar('general', 'figshare_consumer_key');
		$consumer_secret = Config::getVar('general', 'figshare_consumer_secret');

		$oauth = new OAuth($consumer_key, $consumer_secret);
		$oauth->setToken($_SESSION['req_token'], $_SESSION['req_secret']);

		$response = $oauth->getAccessToken(
			'http://api.figshare.com/v1/pbl/oauth/access_token?oauth_verifier=' . $_GET["oauth_verifier"]
		);

		var_dump($response);

		echo 'token:' . $response['oauth_token'];

		$_SESSION['oauth_token'] = $response['oauth_token'];
		$_SESSION['oauth_token_secret'] = $response['oauth_token_secret'];

		//header('Location: http://ojs.dev.localhost/index.php/test/figshare/submission/' . $article_id);
	}

Open in new window


The req_token and req_secret are okay, they get returned okay and are set. But when I run the getAccessToken I get the following error message:

Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 405, expected HTTP/1.1 20X or a redirect)'

If i attempt to add the oauth_verifier as part of an array like:

$response = $oauth->getAccessToken(
			'http://api.figshare.com/v1/pbl/oauth/access_token',
			array('oauth_verifier' => $_GET["oauth_verifier"])
		);

Open in new window


I get the same error.
up-techAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Have a look at their PHP example.  It shows them using a different OAuth method, which makes sense because HTTP 405 means "Method not allowed."
http://api.figshare.com/docs/demo_php.html#sample-code-for-php
0
up-techAuthor Commented:
Turns out you need to set getAccessToken to pass a post using:

getAccessToken($url, null,null, 'POST');

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.