简体   繁体   English

PHP OAuthProvider :: reportProblem“ oauth_parameters_absent”,但是有参数

[英]PHP OAuthProvider :: reportProblem “oauth_parameters_absent” but parameters are there

I have set up an OAuthProvider in Zend Framework2 following the guidelines here: https://toys.lerdorf.com/archives/55-Writing-an-OAuth-Provider-Service.html and here: http://www.lornajane.net/posts/2011/php-oauth-provider-request-tokens . 我已按照以下准则在Zend Framework2中设置了OAuthProvider: https ://toys.lerdorf.com/archives/55-Writing-an-OAuth-Provider-Service.html以及此处: http://www.lornajane。 net / posts / 2011 / php-oauth-provider-request-tokens

Once I add the line $this->provider->checkOAuthRequest(); 一旦添加行$this->provider->checkOAuthRequest(); I get a bad request: 我收到一个错误的请求:

400 Bad Request: oauth_problem=parameter_absent&oauth_parameters_absent=oauth_consumer_key%26oauth_signature%26oauth_nonce%26oauth_timestamp 400错误的请求:oauth_problem = parameter_absent&oauth_parameters_absent = oauth_consumer_key%26oauth_signature%26oauth_nonce%26oauth_timestamp

My Headers are as follow: 我的标题如下:

Authorization: OAuth oauth_consumer_key="key",oauth_token="qwerty",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1453821463",oauth_nonce="Iu5qXE",oauth_version="1.0",oauth_signature="KOn7AfMCpRCi1Tei1jMLiZ2eZmo%3D"` 授权:OAuth oauth_consumer_key =“ key”,oauth_token =“ qwerty”,oauth_signature_method =“ HMAC-SHA1”,oauth_timestamp =“ 1453821463”,oauth_nonce =“ Iu5qXE”,oauth_version =“ 1.0”,oauth_signature =“ KOn7AfMCpZiZ1J1T

All of my headers show up in the request headers, and it doesn't say any of the other parameters are absent like version or oauth_token 我的所有标头都显示在请求标头中,但并不表示没有其他任何参数,例如versionoauth_token

I have tried searching around and keep scratching my head, any help is appreciated. 我已尝试四处搜寻并不断挠头,不胜感激。

Thank you. 谢谢。

Not sure if this will help others but I found the issue to my solution: 不知道这是否会帮助其他人,但我发现了解决方案的问题:

When I instantiated the OAuthProvider() the first time (as per the docs) it yelled at me to provide a signature method in the constructor, so I did. 当我第一次实例化OAuthProvider()时(根据文档),它大叫我在构造函数中提供签名方法,所以我做到了。 After days of scratching my head trying to figure out why this kept giving me errors I removed the signature method parameter from the constructor like the references above. 经过数天的努力,试图弄清为什么这总是给我带来错误,我像上面的参考文献一样从构造函数中删除了签名方法参数。

After this change everything seemed to have solved itself out.. I am not sure as to why this happened but it doesn't error back at me now, and sets up the $provider with its oauth parameters. 进行此更改后,一切似乎都已解决。.我不确定为什么会发生这种情况,但现在并不会出错,并使用其oauth参数设置了$ provider。

My Code: 我的代码:

$provider = new OAuthProvider();
$provider->consumerHandler(array($this,'lookupConsumer'));
$provider->timestampNonceHandler(array($this,'lookupNonce'));
$provider->tokenHandler(array($this,'lookupToken'));
$provider->setRequestTokenPath('/oauth/request-token');
$provider->checkOAuthRequest();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM