我有一个关于Podio认证的谜题。如果没有下面的致命错误,我无法完成一些事情。我这样做:Podio::authenticate_with_password('aaa', 'bbb');
我明白了:PHP Fatal error: Uncaught PodioRateLimitError: "You have hit the rate limit. Please wait 300 seconds before trying again"
我的系统可以处理在许多空间中划分的复杂关系,这就是为什么我创建了一个“主”帐户,它在每个目标空间中都有管理员的角色。
每次调用web钩子时,我都会使用“主”帐户进行身份验证(由于同一脚本中的多个关系,使用app进行身份验证将是一项艰巨的工作)。
同一个web钩子被多次调用,但在不同的上下文中。
我怎样才能避免每次我的网钩被调用时利率上限被打破?我尝试了OAuth 2,但是的Podio文档对我的例子没有帮助。没有尝试对我有效。
您是否有任何方法保存在内存/数据库身份验证数据中,以便能够将其用于来自多个web钩子调用的每个password身份验证?
任何帮助都将非常感谢!
解决方案
我在Podio类中发现了一些有趣的东西:
我就是这样做的:
// Set user API key
Podio::setup('user-key', 'wejt9wetwerith34rtfhwetu34hwerud);
// Init refresh_token variable (avoid PHP warning if any refresh_token found in database)
$refresh_token = null;
// Get refresh_token from database if exists
$refresh_token = REFRESH_TOKEN_FROM_DATABASE;
// Authenticate
try{
// Authenticate with refresh token stored in database
Podio::authenticate( 'refresh_token', array( 'refresh_token' => $refresh_token ) );
}
// Authentication failed, request new refresh_token
catch ( Exception $ex ) {
Podio::authenticate_with_password( 'aaa', 'bbb' );
// Get Oauth data including refresh token
$oauth = Podio::$oauth;
// Authenticate with refresh token
Podio::authenticate( 'refresh_token', array( 'refresh_token' => $oauth->refresh_token ) );
// Store $oauth->refresh_token in database for next webhook call...
}非常重要,在脚本中使用相同的用户API密钥,以避免身份验证限制破坏,因为refresh_token链接到用于发出请求的用户API密钥。
发布于 2018-05-10 12:23:35
答案将在解决方案部分中的原始文章中描述。
发布于 2018-05-01 13:40:37
Podio文件:
https://stackoverflow.com/questions/50116345
复制相似问题