Google 身份验证令牌在 Android 上多久过期?(或:如何不打扰奶奶) [英] how often do Google auth tokens expire on Android? (or: how not to bother Grandma)

查看:107
本文介绍了Google 身份验证令牌在 Android 上多久过期?(或:如何不打扰奶奶)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我奶奶在 Android 上编写一个相框应用程序,该应用程序会自动更新她 Picasa 相册中的图片.(并不是说她知道 Picasa 是什么.)该应用程序将使用她注册的 Google 帐户自动登录 Picasa.(并不是说她知道什么是 Google 帐户,或者她有一个.)

I'm writing a picture frame app for my grandma on Android that will update automatically with pictures from her Picasa album. (Not that she knows what Picasa is.) The app will log in to Picasa automatically using her registered Google account. (Not that she knows what a Google account is, or that she has one.)

通过大量的痛苦和阅读错误/晦涩/矛盾/模糊的文档,我慢慢开始让我的应用程序使用默认的 Android Google 帐户进行身份验证.当然,第一次访问时,我会收到通知,我必须输入 Google 密码.然后,我会获得一个可用于未来请求的身份验证令牌,以便图片查看者可以愉快地更新其照片,而无需打扰奶奶输入密码.

Through much pain and reading erroneous/obscure/contradictory/vague documentation, I am slowly starting to have my app authenticate itself using the default Android Google account. Of course the first time that access is made, I get a notification and I must enter the Google password. I then get an auth token I can use for future requests, so that the picture viewer can happily update its photos without bothering Grandma to enter some password.

问题:我的 Picasa 身份验证令牌多久会过期?一小时?一天?一周?我的图片查看器会突然停止向奶奶显示图片并要求她输入密码吗?这个练习的全部目的是让奶奶的事情变得容易.

The question: how long will it be until my auth token to Picasa will expire? An hour? A day? A week? Will my picture viewer suddenly stop showing pictures to Grandma and ask her to enter her password? The whole point of this exercise is to make things easy for Grandma.

推荐答案

它们不会持续那么久,但是你只需调用 AccountManager.invalidateAuthToken()401 或 403,然后重新调用 AccountManager.getAuthToken() 以获取新令牌.第一次运行应用程序时,奶奶只需要说一次 OK.

They don't last all that long, but you just call AccountManager.invalidateAuthToken() on a 401 or 403, and then re-call AccountManager.getAuthToken() to get a new token. Grandma only has to say OK once, the first time she runs the app.

这篇关于Google 身份验证令牌在 Android 上多久过期?(或:如何不打扰奶奶)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆