dongyou6768 2016-11-14 19:02
浏览 18
已采纳

多次呼叫后,Podio身份验证失败

I've been working with the Podio API for nearly a year now and have rarely had issues, but I recently ran into one that I can't figure out. I'm not even sure how to test what is going on. When an item is created, I have a webhook to a script which will send an http GET request to an item and perform a number of functions. The script runs just fine and has never run into any issues, unless I create a number of items in quick succession (15 or so). If I do this, a certain number will finish successfully, and then I will suddenly get the following error with each new call:

2016-11-14 16:41:14 401 GET /item/514610204
2016-11-14 16:41:14 Reponse: {"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http:\/\/api.podio.com\/item\/514610204","query_string":"","method":"GET "},"error_description":"invalid_request","error":"unauthorized"}

If I wait a minute or so, it begins working again.

I'm authenticating with username and password. Does anyone know what is going on or how to check what is going on? The podio.log has not been helpful in this situation.

(UPDATE) The issue is that I am hitting an authentication request rate limit because I haven't been using a session manager. I'm now attempting to do this, but having issues. My code using the Redis setup is as follows:

require_once 'models/PodioRedisSession.php';

Podio::set_debug(true, 'file');
Podio::setup($client_id, $client_secret,array(
  "session_manager" => "PodioRedisSession"
));

Podio::$auth_type = array(
  "type" => "password",
  "identifier" => "MY_EMAIL"
);
Podio::$oauth = self::$session_manager->get(Podio::$auth_type); //ERROR IS ON THIS LINE

if (!Podio::is_authenticated()) {

  Podio::authenticate_with_password('MY_EMAIL', 'MY_PASSWORD');
}

which gives me the following error: Cannot access self:: when no class scope is active. Am I on the right track to get the session manager working with password authentication? The error occurs on the commented line.

(UPDATE) I was finally able to get the system running properly. The code above is correct. The server just needed to be reset (Windows server) for Redis to take affect.

  • 写回答

2条回答 默认 最新

  • douchao1879 2016-11-17 14:57
    关注

    To avoid hitting this limit you should authenticate with the API once and then store the oauth and refresh tokens that at are returned from the API. Redis will do the trick. Then you use the oauth token for all subsequent requests.

    An example can be found here [1]

    Your oauth token will be valid for at most 28 days. When it's no longer valid you will need to obtain a new oauth token using the refresh token you received when you first authenticated. [2]

    [1] https://developers.podio.com/authentication/username_password

    [2] https://developers.podio.com/authentication

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办