在没有浏览器的 Play 服务器中进行身份验证
Authentication in a Play server without browser
所以,我有一个 Android 应用程序,这意味着我没有使用浏览器(我将在几行中解释为什么这很重要)并且我希望在 Play 中使用 Security.Authenticator ! 2.3.8
基本上,Play 使用当前会话(与浏览器直接相关),使用 String getUserame(Context ctx)
检查其中的内容,如果存在则发回用户名。如果没有,那么 returns a HTTP redirect
using Result onUnauthorized(Context ctx)
这是我的问题:我使用 Play 作为远程应用程序的服务器。如何在我的应用程序中使用 Play 提供的身份验证方法?这当然很棘手,因为我没有使用任何浏览器,所以我无法在会话中存储一些东西。
你们对此有什么解决方法或解决方案吗?
Play uses the current session (which is directly related to the browser)...
I can't store something in session due to the fact I'm not using any
browser.
以上是错误的。
您可以轻松地将 cookie 存储在 Android 的 CookieStore 中,这样您就可以安全地使用 Play 的会话 cookie。
相关的 SO 问题将帮助您弄清楚如何做到这一点 Android 方面:
Android: How to store cookies?
Storing and restoring cookies in Android (persistent cookie storage)
所以,我有一个 Android 应用程序,这意味着我没有使用浏览器(我将在几行中解释为什么这很重要)并且我希望在 Play 中使用 Security.Authenticator ! 2.3.8
基本上,Play 使用当前会话(与浏览器直接相关),使用 String getUserame(Context ctx)
检查其中的内容,如果存在则发回用户名。如果没有,那么 returns a HTTP redirect
using Result onUnauthorized(Context ctx)
这是我的问题:我使用 Play 作为远程应用程序的服务器。如何在我的应用程序中使用 Play 提供的身份验证方法?这当然很棘手,因为我没有使用任何浏览器,所以我无法在会话中存储一些东西。
你们对此有什么解决方法或解决方案吗?
Play uses the current session (which is directly related to the browser)... I can't store something in session due to the fact I'm not using any browser.
以上是错误的。
您可以轻松地将 cookie 存储在 Android 的 CookieStore 中,这样您就可以安全地使用 Play 的会话 cookie。
相关的 SO 问题将帮助您弄清楚如何做到这一点 Android 方面:
Android: How to store cookies?
Storing and restoring cookies in Android (persistent cookie storage)