I'm trying to authenticate my application with the ETrade API using OAuth. After I redirect the browser to ETrade for the user to authenticate, the callback URL is the same page the user started with (I go back to the same page in order to finish off the authentication). However, once it's redirected back to the same page, the redirect to ETrade happens again. How would I do this so the app isn't redirected but rather can finish off the authentication? Thanks!
PHP:
require_once("./autotrading/SDK/samples/config.php");
require_once("./autotrading/SDK/Common/common.php");
$key = ETWS_APP_KEY;
$secret = ETWS_APP_SECRET;
$consumer = new etOAuthConsumer($key, $secret);
$request = new etOAuth($consumer);
$req_token = $request->GetRequestToken();
$oauthToken = $req_token['oauth_token'];
$oauthSecret = $req_token['oauth_token_secret'];
$authURL = $request->GetAuthorizeURL();
header('Location: '.$authURL);
//after authenticating, etrade's callback url looks like this: http://yourdomain.com/index.php?oauth_token=abc&oauth_verifier=123
if(isset($_GET['oauth_verifier'])) {
$verifierCode = trim($_GET['oauth_verifier']);
echo $verifierCode;
$accessCode = GetAccessToken($verifierCode);
}
For reference, here's the API: https://developer.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-SDKGuides-PHP