Note that there are some explanatory texts on larger screens.

plurals
  1. PODifficulty requesting the Access Token With OAuth? Error: No token or token_secret
    text
    copied!<p>I'm hoping someone might be able to answer. I've been working on this for many hours and can't find the solution. I've also studied the HTTP_OAUTH <a href="http://pear.php.net/package/HTTP_OAuth/docs/latest/__filesource/fsource_HTTP_OAuth__HTTP_OAuth-0.1.7HTTPOAuthConsumer.php.html" rel="nofollow">documentation</a> over and over as well as some tutorials. I'm stuck using that because my host doesn't support normal OAuth. That aside, it's not so bad. This is what I have so far. I'm able to:</p> <ol> <li>Acquire an access token (URL_PATH_GOES_HERE?<strong>oauth_token=XXXXXXXXXXXXX</strong>)</li> <li>Redirect the user to get their permission</li> <li>Redirect back to my callback URL with an access token and oauth_verifier(URL_PATH_GOES_HERE?<strong>oauth_token=XXXXXXXXXXXXX?oauth_verifier=XXXXXXXXXX</strong>)</li> </ol> <p>When I get there, however, I'm having difficulty requesting the Access Token so I can from there on out make requests on behalf of the user.</p> <p>I keep getting the error: </p> <blockquote> <p>No token or token_secret</p> </blockquote> <p>Any ideas? I'd be eternally grateful!! </p> <pre><code>############################## ## FILNENAME: msconfig.php ### ############################## &lt;?php define('OAUTH_CONSUMER_KEY',CONSUMER KEY GOES HERE); define('OAUTH_CONSUMER_SECRET',CONSUMER SECRET GOES HERE); define('OAUTH_REQUEST_TOKEN_API', 'http://gomiso.com/oauth/request_token'); define('OAUTH_AUTHORIZE_API', 'http://gomiso.com/oauth/authorize'); define('OAUTH_ACCESS_TOKEN_API', 'http://gomiso.com/oauth/access_token'); define('CALLBACK_URL', 'URL_PATH_GOES_HERE/callback.php'); define('MISO_USER_AGENT', 'youruseragent'); ?&gt; ############################### ### FILNENAME: index.php ###### ############################### &lt;?php //########################################################################## // START A SESSION SO WE CAN SHARE VARIABLES WITH OUR CALLBACK HANDLER ##### //########################################################################## session_start(); //############################ // IMPORT CONFIGURATION FLE ## //############################ require_once("misoconfig.php"); //########################## //#IMPORT EXTERNAL CLASSES # //########################## require_once("HTTP/OAuth/Consumer.php"); //######################## //# FETCH REQUEST TOKEN ## //######################## try { $consumer = new HTTP_OAuth_Consumer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET); $consumer-&gt;getRequestToken(OAUTH_REQUEST_TOKEN_API,CALLBACK_URL); $_SESSION['request_token'] = $consumer-&gt;getToken(); }catch (Exception $e) { echo 'Fetching Request Token Exception: ', $e-&gt;getMessage(), "\n"; } //############################################# // REDIRECT THE USER TO THE AUTHORIZATION URL # //############################################# try { $url = $consumer-&gt;getAuthorizeUrl(OAUTH_AUTHORIZE_API); header("Location: $url"); }catch (Exception $e) { echo 'Authorization URL Redirection Exception: ', $e-&gt;getMessage(), "\n"; } ?&gt; ############################## ## FILNENAME: callback.php ### ############################## &lt;?php // START A SESSION SO WE CAN ACCESS VARIABLES SHARED WITH US BY INDEX.PHP session_start(); // IMPORT CONFIGURATION FLE require_once("misoconfig.php"); // IMPORT EXTERNAL CLASSES require_once("HTTP/OAuth/Consumer.php"); // Store these tokens (at least for now) $_SESSION['oauth_verifier'] = $_GET['oauth_verifier']; // BY REACHING THIS FAR, WE'VE BEEN AUTHENTICATED. LET'S GRAB THE ACCESS TOKEN AND SECRET AND SAVE THEM &lt;SOMEWHRE&gt;. try { $consumer = new HTTP_OAuth_Consumer($_SESSION['request_token'], $_SESSION['oauth_verifier']); $consumer-&gt;getAccessToken(OAUTH_ACCESS_TOKEN_API,$_SESSION['oauth_verifier'],array(),'GET'); }catch (Exception $e) { echo 'Access Token Exception: ', $e-&gt;getMessage(), "\n"; } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload