我想知道在移动应用程序上存储密钥以进行会话认证的机制。我有一个Tornado网络服务器,它将使用第三方外部服务来验证用户身份,例如Facebook或Google。使用浏览器时,我熟悉使用set_secure_cookie
存储cookie。但是,如果移动应用程序现在正在连接并进行身份验证,该怎么办。我将使用什么机制来存储secret(如安全cookie)以用于将来的会话身份验证?下面显示了验证用户的代码:
class GoogleOAuth2LoginHandler(tornado.web.RequestHandler,
tornado.auth.GoogleOAuth2Mixin):
async def get(self):
if self.get_argument('code', False):
user = await self.get_authenticated_user(
redirect_uri='http://your.site.com/auth/google',
code=self.get_argument('code'))
# Save the user with e.g. set_secure_cookie
else:
await self.authorize_redirect(
redirect_uri='http://your.site.com/auth/google',
client_id=self.settings['google_oauth']['key'],
scope=['profile', 'email'],
response_type='code',
extra_params={'approval_prompt': 'auto'})
将如何修改不依赖浏览器和cookie支持的移动应用程序?