ASP.NET MVC C# uygulamasından FreshBooks API için kimlik doğrulama için OAuth kullanmaya çalışıyorum. İşte ben bugüne kadar ne var: Burada DotNetOpenAuth kullanıyorumDotNetOpenAuth üzerinden FreshBooks Kimlik Doğrulaması
olan benim denetleyicisi eylem var kod
if (TokenManager != null)
{
ServiceProviderDescription provider = new ServiceProviderDescription();
provider.ProtocolVersion = ProtocolVersion.V10a;
provider.AccessTokenEndpoint = new MessageReceivingEndpoint ("https://myfbid.freshbooks.com/oauth/oauth_access.php", DotNetOpenAuth.Messaging.HttpDeliveryMethods.PostRequest);
provider.RequestTokenEndpoint = new DotNetOpenAuth.Messaging.MessageReceivingEndpoint("https://myfbid.freshbooks.com/oauth/oauth_request.php", DotNetOpenAuth.Messaging.HttpDeliveryMethods.PostRequest);
provider.UserAuthorizationEndpoint = new DotNetOpenAuth.Messaging.MessageReceivingEndpoint("https://myfbid.freshbooks.com/oauth/oauth_authorize.php", DotNetOpenAuth.Messaging.HttpDeliveryMethods.GetRequest);
provider.TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() };
var consumer = new WebConsumer(provider, TokenManager);
var response = consumer.ProcessUserAuthorization();
if (response != null)
{
this.AccessToken = response.AccessToken;
}
else
{
// we need to request authorization
consumer.Channel.Send(consumer.PrepareRequestUserAuthorization(
new Uri("http://localhost:9876/home/testoauth/"), null, null));
}
}
TokenManager Ben, DotNetOpenAuth örnek ile sağlanan aynı sınıftır Tüketici sırrını FreshBooks'un bana verdiğini ayarladım. Bunu doğru yapıyor
"The remote server returned an error: (400) Bad Request.".
Am: consumer.Channel.Send(consumer.PrepareRequestUserAuthorization(...))
günü
Ben şu istisna var? Doğru çalışması gereken FreshBooks belgelerine ve DotNetOpenAuth örneklerine dayanmaktadır.
OAuth kimlik doğrulaması kullanmak için DotNetOpenAuth biraz büyük olduğundan, OAuth ile kimlik doğrulamanın daha basit bir yolu var mı?
Teşekkür ben de aynı 400 Geçersiz istek hata var olsa kütüphane, kullanımı basittir itiraf, ben başlayacağım FreshBooks ile ilgili olduğumu düşünmek ve benim uygulamamı değil. Onlarla doğrudan kontrol edeceğim. –