想与Withings API连接。 我用同样的控制器在其他项目中,他完美地工作。 在一个项目中,该网站是一个Azure的webrole(不知道怎么说这个问题),这是行不通的。 首先我
对于“DotNetOpenAuth.Reporting”的类型初始值引发异常。
所以我关闭了它在web.config
报告启用=“假”
现在,我得到
对于“DotNetOpenAuth.Logger”的类型初始值引发异常。
我不使用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
};
}