douweng7308 2015-07-16 00:51
浏览 30

OAuth回调进入循环

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

  • 写回答

2条回答 默认 最新

  • dp152153 2015-08-18 23:57
    关注

    If your callback with etrade is configured properly, you should be getting oauth_verifier in the query string.

    You should be able to trap that oauth_verifier query string element exists and has a value.

    Look at page 16 of the etrade PDF concerning their API.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画