2014-09-03 4 views
1

웹 응용 프로그램에서 Google 스프레드 시트에 액세스해야합니다. 이것은 회원 정보를 Google 스프레드 시트에 쓰는 회원 애플리케이션입니다. 코드를 로컬에서 실행하면 아래 코드가 작동합니다.웹 사이트의 Google API 인증

SpreadsheetsService service = new SpreadsheetsService(spreadsheetName); 
service.setUserCredentials(USERNAME, PASSWORD); 

그러나 웹 응용 프로그램을 서버에서 실행할 때 인증이 실패합니다.

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에 대한 언급이 많이 있습니다. 문제는 사용자의 인증을 사용하고 싶지 않다는 것입니다. 내 웹 앱에서만 제공 한 자격 증명을 사용하여 스프레드 시트에 쓸 수 있어야합니다.

답변