2014-02-06 41 views
0

我正在編寫一個Cordova(PhoneGap)應用程序,該應用程序使用Google App Engine後臺登錄和數據庫。 Google App Engine似乎可以處理應用程序中的所有URL,但這不是Cordova如何操作的。我正在使用users.create_login_url()將用戶引導至Google的登錄頁面。此函數的第一個參數是重定向URL,可以是完整的URL或相對於應用程序的位置。我可以輸入'/home'或某個URL,如'http://google.com',但我希望應用程序重定向回用戶單擊按鈕登錄時所在的Cordova頁面。我輸入了'http://localhost',但我不確定這會按照我預期的方式工作。這工作,還是我需要做別的?Google App Engine登錄URL重定向電話

從本質上講,我提出了使用jQuery.ajax()的登錄請求:

$.ajax({ 
    type:'POST', 
    url:'http://localhost:8090/login', //I am running this in the GAE developer runtime 
    success:function(data) { 
     window.location = data; 
    } 
}); 

上述代碼應調用在我在GAE創建的登錄類後()方法。在該方法中的代碼做到這一點:

def post(self): 
    user = users.get_current_user() 
    if user: 
     self.response.write("userAlreadyLoggedIn") 
    else: 
     self.response.write(users.create_login_url("http://localhost") 

我沒有測試過這還,但忽略任何無關的錯誤,我可能有過,這會做什麼上述我?

回答

相關問題