dpojoxa5613 2012-02-02 05:18
浏览 67
已采纳

Foursquare OAuth2 401错误

Using PHP and curl to generate an access token with this url:

https://foursquare.com/oauth2/access_token?client_id=MY_CLIENT_ID&client_secret=MY_SECRET&grant_type=authorization_code&redirect_uri='.urlencode('MY_REDIRECT_URL').'&code='.$token['oauth_token']

This processes just fine and returns a token. This token only changes when I reset the consumer key and secret at foursquare.com

Using that token with

https://api.foursquare.com/v2/users/search?name=test&oauth_token=RETURNED_TOKEN

always returns a 401 error. I used these instructions https://developer.foursquare.com/overview/auth

  • 写回答

1条回答 默认 最新

  • duanjia7912 2012-02-02 22:09
    关注

    ok here's what was going on:

    in the oauth-php client code, the getQueryString method of the OAuthRequestSigner had the following condition when building the request url query string to prevent adding OAuth 1.0 signed params:

     (strncmp($name, 'oauth_', 6) != 0
    

    I have a config file to manage my OAuth parameters and added

     $param=array(
       ...
       'oauth2'=>true
       ...);
    

    which is passed to the OAuthRequestSigner class and adjusted the condition to

     ( (strncmp($name, 'oauth_', 6) != 0 || $param['oauth2'] )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误