var service = new ServiceProviderDescription
{
RequestTokenEndpoint = new MessageReceivingEndpoint( this._requestTokenUrl, this._requestTokenHttpDeliveryMethod ),
UserAuthorizationEndpoint = new MessageReceivingEndpoint( this._authorizeUrl, HttpDeliveryMethods.GetRequest ),
AccessTokenEndpoint = new MessageReceivingEndpoint( this._accessTokenUrl, this._accessTokenHttpDeliveryMethod ),
TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() },
ProtocolVersion = ProtocolVersion.V10a,
};
this._tokenManager = new InMemoryTokenManager();
this._tokenManager.ConsumerKey = this._consumerKey;
this._tokenManager.ConsumerSecret = this._consumerSecretKey;
this._consumer = new DesktopConsumer( service, this._tokenManager );
this._accessToken = string.Empty;
consumer.RequestUserAuthorization( null, null, out this.requestToken );
当_requestTokenUrl等于例如127.0.0.1:1234/magento时 - 方法抛出异常,因为服务器返回:401 oauth_problem = signature_invalid
但是如果我使用127.0.0.1/magento它可以正常工作。
如何使用包含端口的URL的RequestUserAuthorization()?
答案 0 :(得分:0)
我发现解决方案不是在DotNetOpanAuth中,而是在magento中。默认情况下,magento在Mage_Oauth_Model_Server::_validateSignature()
中计算签名时忽略端口。要更改它,您必须将false参数传递给$this->_request->getHttpHost()
。
可能是Magento Rest Oauth API (Signature Invalid) 401