我試圖在Google dotnet客戶端庫中將DotNetOpenAuth
verson升級到4.2.2.13055
。 所以我下載了最新的dll - DotNetOpenAuth.Core,DotNetOpenAuth.OAuth2等等(我們仍然不能用於NuGet)。ProcessUserAuthorization上的錯誤請求(DotNetOpenAuth 4.2.2.13055)
我做了一個小改動(改變了我用Client_id和client_secret構造NativeApplcationClient的方式)以支持新版本。 於是,我試圖運行的樣本,我們在我們的樣本庫(如https://code.google.com/p/google-api-dotnet-client/source/browse/Tasks.SimpleOAuth2/Program.cs?repo=samples),我得到了一個壞請求錯誤,如下:
DotNetOpenAuth.Messaging.ProtocolException: Error occurred while sending a direct message or getting the response. --->
System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions opt
ions)
--- End of inner exception stack trace ---
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions opt
ions)
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request)
at DotNetOpenAuth.Messaging.Channel.GetDirectResponse(HttpWebRequest webRequest)
at DotNetOpenAuth.Messaging.Channel.RequestCore(IDirectedProtocolMessage request)
at DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage)
at DotNetOpenAuth.OAuth2.ClientBase.UpdateAuthorizationWithResponse(IAuthorizationState authorizationState, EndUserAu
thorizationSuccessAuthCodeResponse authorizationSuccess)
at DotNetOpenAuth.OAuth2.UserAgentClient.ProcessUserAuthorization(IAuthorizationState authorizationState, IDirectedPr
otocolMessage response)
at DotNetOpenAuth.OAuth2.UserAgentClient.ProcessUserAuthorization(Uri actualRedirectUrl, IAuthorizationState authoriz
ationState)
at Google.Apis.Authentication.OAuth2.DotNetOpenAuth.NativeApplicationClient.ProcessUserAuthorization(String authCode,
IAuthorizationState authorizationState) in c:\code.google.com\google-api-dotnet-client\default_oauth2\Src\GoogleApis.Au
thentication.OAuth2\DotNetOpenAuth\NativeApplicationClient.cs:line 102
at Google.Apis.Samples.TasksOAuth2.Program.GetAuthorization(NativeApplicationClient arg) in c:\code.google.com\google
-api-dotnet-client\samples_oauth2\Tasks.SimpleOAuth2\Program.cs:line 73
at Google.Apis.Authentication.OAuth2.OAuth2Authenticator`1.LoadAccessToken() in c:\code.google.com\google-api-dotnet-
client\default_oauth2\Src\GoogleApis.Authentication.OAuth2\OAuth2Authenticator.cs:line 124
我注意到也有第二請求的不同(通過令牌交換代碼):授權頭被添加到請求中,並且正文缺少我的client_id和client_secret。
類似代碼對老版本 - 4.0.0.11165, 我錯過了什麼?
但正如我所提到的在新版本中,令牌交換請求(grant_type = authorization_code)中缺少client_id和client_secret。 在更改之前,body包含代碼 redirect_uri,grant_type = authorization_code,client_id和client_secret。 在新的請求中client_id和client_secret缺失,授權標頭被添加到請求 – peleyal 2013-03-08 19:34:13
然後你剛剛確認我的答案。 – 2013-03-09 14:42:57
我還需要爲box.com api執行此操作。 – 2013-09-22 12:24:45