Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 从基于GAE的应用程序获取身份验证Cookie的正确URL是什么_Android_Google App Engine_Authentication_Cookies_Token - Fatal编程技术网

Android 从基于GAE的应用程序获取身份验证Cookie的正确URL是什么

Android 从基于GAE的应用程序获取身份验证Cookie的正确URL是什么,android,google-app-engine,authentication,cookies,token,Android,Google App Engine,Authentication,Cookies,Token,我有一个android应用程序,我想连接到基于谷歌应用程序引擎的服务器。我可以从AccountManager获得身份验证令牌。看来我接下来要做的就是和授权页面对话,得到一个cookie。按照此处的说明进行操作: 我认为我的url应该是: https://MYAPP.appspot.com/_ah/login?continue=http://localhost/&auth=CrAZYl000ngToken 但我得到的不是重定向,而是500服务器错误: Error: Server Erro

我有一个android应用程序,我想连接到基于谷歌应用程序引擎的服务器。我可以从AccountManager获得身份验证令牌。看来我接下来要做的就是和授权页面对话,得到一个cookie。按照此处的说明进行操作: 我认为我的url应该是:

https://MYAPP.appspot.com/_ah/login?continue=http://localhost/&auth=CrAZYl000ngToken
但我得到的不是重定向,而是500服务器错误:

Error: Server Error

The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message 
and the query that caused it.

怎么回事?我应该访问的URL是什么?或者我做错了什么?

好吧,URL毕竟没有错。问题是令牌已过期。我可以通过使令牌失效并重新获取令牌来解决这个问题

private class GetAuthTokenTask extends AsyncTask<Account, Object, String> {

    @Override
    protected String doInBackground(Account... accounts) {
        AccountManager manager = AccountManager.get(getApplicationContext());
        Account account = accounts[0];
        String token = this.buildToken(manager, account);
        manager.invalidateAuthToken(account.type, token);
        return this.buildToken(manager, account);
    }

    private String buildToken(AccountManager manager, Account account) {
        try {
            AccountManagerFuture<Bundle> future = manager.getAuthToken (account, "ah", false, null, null);
            Bundle bundle = future.getResult();
            return bundle.getString(AccountManager.KEY_AUTHTOKEN);
         } catch (OperationCanceledException e) {
                Log.w(TAG, e.getMessage());
         } catch (AuthenticatorException e) {
                Log.w(TAG, e.getMessage());
         } catch (IOException e) {
                Log.w(TAG, e.getMessage());
         }
         return null;
    }

    protected void onPostExecute(String authToken) {
        new GetCookieTask().execute(authToken);    
    }
}
私有类GetAuthTokenTask扩展了AsyncTask{
@凌驾
受保护字符串doInBackground(帐户…帐户){
AccountManager=AccountManager.get(getApplicationContext());
账户=账户[0];
String token=this.buildToken(经理、帐户);
manager.invalidateAuthToken(account.type,token);
返回此.buildToken(经理、帐户);
}
私有字符串buildToken(AccountManager,Account Account){
试一试{
AccountManagerFuture=manager.getAuthToken(帐户,“ah”,false,null,null);
Bundle=future.getResult();
返回bundle.getString(AccountManager.KEY\u AUTHTOKEN);
}捕捉(操作取消异常e){
Log.w(标记,e.getMessage());
}捕获(认证异常e){
Log.w(标记,e.getMessage());
}捕获(IOE异常){
Log.w(标记,e.getMessage());
}
返回null;
}
受保护的void onPostExecute(字符串authToken){
新建GetCookieTask().execute(authToken);
}
}

这确实解决了我3小时的问题!我正在使auth令牌无效,但令牌参数为null。这是我能发现的唯一区别。但是,当需要用户操作来接受登录时,您如何处理这种情况,那么捆绑包应该包含一个意图。它仍然适用于您吗?我已经开始重定向到
https://www.google.com/accounts/ServiceLogin?service=ah&passive=true&继续=https://appengine.google.com/_ah/conflogin%3Fcontinue%3D&ltmpl=gm&;shdf=OTHERCRAZYTOKEN