【问题标题】:Web request to 'https://accounts.google.com/o/oauth2/token' failed using webapplication使用 Web 应用程序对“https://accounts.google.com/o/oauth2/token”的 Web 请求失败
【发布时间】:2013-08-09 11:44:47
【问题描述】:

我在 GoogleConsoleAPI 中有 SERVICE 帐户。我的控制台应用程序工作正常,我正在从 GoogleAnalytics 获取数据但是当我在 WEB 应用程序中实现相同的代码并尝试访问数据时 我得到了例外

消息 - ProtocolException 被捕获。 对“https://accounts.google.com/o/oauth2/token”的 Web 请求失败。

StackTrace - 在 c:\code.google.com\google-api-dotnet-client\default\Tools\BuildRelease\bin\Release\release140\default 中的 Google.Apis.Requests.ClientServiceRequest`1.Execute() \Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:第 88 行 在 GoogleAnalyticsDataAccess.GoogleDataAccess.GetDataFromGoogle(GoogleParameterEntity gparamEntity) 在 C:\Users\g.shirpurkar\Documents\Visual Studio 2010\Projects\GoogleAnalyticsDataAccess\GoogleAnalyticsDataAccess\GoogleDataAccess.vb:line 94

内部异常 -

   at System.Net.Security.SecureChannel.VerifyRemoteCertificate(RemoteCertValidationCallback remoteCertValidationCallback)
   at System.Net.Security.SslState.CompleteHandshake()
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.TlsStream.CallProcessAuthentication(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetRequestStreamCore(HttpWebRequest request)

有人建议我,对于 web 应用程序,我使用相同的服务帐户。它是否正确 ?如果没有请告诉我步骤,如何解决这个问题?

【问题讨论】:

标签: asp.net google-analytics google-analytics-api google-api-dotnet-client


【解决方案1】:

对我有用的是确保范围设置是这样的: https://www.googleapis.com/auth/analytics.readonly 而不仅仅是“analytics.readonly”

【讨论】:

    猜你喜欢
    • 2018-08-04
    • 2014-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-12
    • 2021-09-29
    相关资源
    最近更新 更多