本文介绍了同时采用DotnetopenAuth报告和记录错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
想和Withings API连接。我用同样的控制器在其他项目中,他完美地工作。在一个项目中,该网站是一个蓝色的webrole(不知道怎么说这个问题),它只是不工作。首先,我得到了
So I turned it off in the web.config
Now I got
I don't use log4net.
public ActionResult StartOAuth()
{
var serviceProvider = GetServiceDescription();
var consumer = new WebConsumer(serviceProvider, _tokenManager);
// Url to redirect to
var authUrl = new Uri(Request.Url.Scheme + "://" + Request.Url.Authority + "/Withings/OAuthCallBack");
// request access
consumer.Channel.Send(consumer.PrepareRequestUserAuthorization(authUrl, null, null));
// This will not get hit!
return null;
}
private ServiceProviderDescription GetServiceDescription()
{
return new ServiceProviderDescription
{
AccessTokenEndpoint = new MessageReceivingEndpoint("https://oauth.withings.com/account/access_token", HttpDeliveryMethods.PostRequest),
RequestTokenEndpoint = new MessageReceivingEndpoint("https://oauth.withings.com/account/request_token", HttpDeliveryMethods.PostRequest),
UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://oauth.withings.com/account/authorize", HttpDeliveryMethods.PostRequest),
TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() },
ProtocolVersion = ProtocolVersion.V10a
};
}
解决方案
So it turns out it was Azure's fault. In web.config
there is a section which broke DotnetOpenAuth. Deleting this section is a workaround. Probably adding log4net would also fix this issue, but I didn't test.
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
这篇关于同时采用DotnetopenAuth报告和记录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!