-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception: Invalid Authentication State "STATE" #17
Comments
很明显,你指定的 state 参数 "STATE" 没有通过验证! 为什么要验证 state 参数? http://www.twobotechnologies.com/blog/2014/02/importance-of-state-in-oauth2.html 如何手动指定 state?
use Thenbsp\Wechat\OAuth\Client;
// 生成一个随机的 state
$state = rand(1000, 9999);
$client = new Client('appid', 'appsecret');
// 手动指定 state
$client->setState($state);
if( !isset($_GET['code']) ) {
header('Location: '.$client->getAuthorizeUrl());
}
// 获取 AccessToken 时验证之前设置过的 state 是否有效
// callback_url 中会带上之前设置过的 state
$accessToken = $client->getAccessToken($_GET['code'], $_GET['state']);
var_dump($accessToken->toArray()); 如果你不想手动传入 use Thenbsp\Wechat\OAuth\Client;
$client = new Client('appid', 'appsecret');
if( !isset($_GET['code']) ) {
header('Location: '.$client->getAuthorizeUrl());
}
$accessToken = $client->getAccessToken($_GET['code']);
var_dump($accessToken->toArray()); 详情请参考:https://github.com/thenbsp/wechat/wiki/oauth_client |
我调用的代码如下,没有手动设置 state 的啊
|
请尝试手动指定 state:
|
麻烦问下stateManager是缓存在文件里面吗?使用中授权回调回来都提示state参数不通过验证 |
在调用过程中的
Thenbsp\Wechat\OAuth\AbstractClient->getAccessToken('011h65fm0KiPfo1...')
Exception: Invalid Authentication State "STATE" in thenbsp/wechat/src/OAuth/AbstractClient.php:113
请问什么原因??Thanks
The text was updated successfully, but these errors were encountered: