2010-02-21 60 views
4

我正在寫一個谷歌appengine應用程序,其中存儲數據和Web前端。我希望能夠在C#程序中下拉這些數據。這意味着我需要對網站進行身份驗證(用戶必須登錄才能查看數據)。我如何進行身份驗證?我嘗試在WebClient上設置憑據,但我一直在獲取Google登錄頁面。與來自C的谷歌appengine互動#

WebClient client = new WebClient(); 
client.Credentials = new NetworkCredential("username", "password"); 
//should it be [email protected] ?? 

client.BaseAddress = "http://nosoperor-internal.appspot.com"; 

String s = client.DownloadString("/bank"); 
//s now contains the google login page, unfortunately 
+0

什麼樣的登陸計劃的網站是否聘用? HTTP基本/摘要,表單+ cookie? – 2010-02-21 21:39:24

+0

我不知道,無論默認爲appengine – Martin 2010-02-21 22:27:37

回答

2

據我所知,你需要可能使用Google Data protocolsaccount APIs進行身份驗證。

編輯:我會download the .Net client library並嘗試在那裏的例子。這是從一個docs複製粘貼:

Service service = new Service("cl", "exampleCo-exampleApp-1")); 
// Set your credentials: 
service.setUserCredentials("[email protected]", "mypassword"); 
+0

hmm,這看起來可能是答案,但我不知道。關於這個的更多細節? – Martin 2010-02-21 22:46:43

+0

我認爲你特別想看看ClientLogin部分:http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html – 2010-02-22 01:27:04

+0

事情是,我認爲我的應用程序不算作服務,據推測我需要重寫應用程序來處理像這樣的自動登錄?我對網絡編程知之甚少,無法做到這一點 – Martin 2010-02-23 11:16:52