1
我需要从我的web应用程序访问Google Spreadsheet。这是一个会员信息写入谷歌电子表格的会员申请。 当我在本地运行代码时,下面的代码工作。来自网站的Google API身份验证
SpreadsheetsService service = new SpreadsheetsService(spreadsheetName);
service.setUserCredentials(USERNAME, PASSWORD);
但是,当我在服务器上运行Web应用程序时,验证失败。
Google.GData.Client.InvalidCredentialsException: Invalid credentials
at Google.GData.Client.Utilities.QueryClientLoginToken(GDataCredentials gc, String serviceName, String applicationName, Boolean fUseKeepAlive, IWebProxy proxyServer, Uri clientLoginHandler)
at Google.GData.Client.GDataGAuthRequest.QueryAuthToken(GDataCredentials gc)
at Google.GData.Client.GDataGAuthRequest.EnsureCredentials()
at Google.GData.Client.GDataRequest.EnsureWebRequest()
at Google.GData.Client.GDataGAuthRequest.EnsureWebRequest()
at Google.GData.Client.GDataRequest.Execute()
at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)
at Google.GData.Client.GDataGAuthRequest.Execute()
at Google.GData.Client.Service.Query(Uri queryUri, DateTime ifModifiedSince, String etag, Int64& contentLength)
at Google.GData.Client.Service.Query(FeedQuery feedQuery)
我也得到了这封邮件来自谷歌:
Hi xxxxxx,
Someone recently used your password to try to sign in to your Google Account
[email protected] This person was using an application such as an email client
or mobile device.
We prevented the sign-in attempt in case this was a hijacker trying to access
your account. Please review the details of the sign-in attempt:
我知道证书是正确的,因为他们在本地测试时正常工作。
我看到很多提及OAuth身份验证。问题是我不想使用用户的身份验证。只有我的网络应用程序应该被允许使用我提供的凭据写入电子表格。