Android C2DM Auth 令牌,一次或每次
我概述了在应用程序中实施 C2DM 的计划,并有一个关于 Auth 令牌的基本(阅读:愚蠢)问题。
客户端服务器需要使用白名单帐户向 google c2dm 服务注册:
用于测试:
curl https://www.google.com/accounts/ClientLogin -d Email=theEmailYouWhitelisted -d Passwd=pass****word -d accountType=HOSTED_OR_GOOGLE -d source="your_app_name_and_ver_for_logging_purposes_only" -d service=ac2dm
我的问题是,每个应用程序每个 c2dm 帐户是否会发生一次这种情况 - 即:使用您的白名单帐户获取一个服务器生成的身份验证代码,并将其存储,然后每次发送消息时检索它并使用:
curl --header "Authorization: GoogleLogin auth=**authFromRegistrationAbove**" "https://android.apis.google.com/c2dm/send" -d registration_id=**phoneRegistrationId(reciever)** -d "data.message=StringToPass" -d collapse_key=something -k
或者您是否必须为每条推送的消息请求新的身份验证代码?
I am outlining my plan to implement C2DM into an application and have a basic (read: stupid) question about the Auth tokens.
The client server needs to register with the google c2dm service using the white listed account:
For testing:
curl https://www.google.com/accounts/ClientLogin -d Email=theEmailYouWhitelisted -d Passwd=pass****word -d accountType=HOSTED_OR_GOOGLE -d source="your_app_name_and_ver_for_logging_purposes_only" -d service=ac2dm
My question is, does this happen once per application per c2dm account - ie: get the one server generated auth code using your whitelisted account, store it, then every time a message gets sent retrieve it and use:
curl --header "Authorization: GoogleLogin auth=**authFromRegistrationAbove**" "https://android.apis.google.com/c2dm/send" -d registration_id=**phoneRegistrationId(reciever)** -d "data.message=StringToPass" -d collapse_key=something -k
Or do you have to request a new Auth code for every message being pushed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
存储身份验证令牌以供将来推送。来自 Google C2DM 页面:
另请注意,Google 将定期刷新
Update-Client-Auth
标头中的令牌。请参阅android-c2dm 上的此讨论
组了解详细信息。根据我的经验,我无法判断 Google 何时或为何选择刷新令牌。这种事每天都会发生在我身上,有时甚至每周都会发生。
Store the auth token for future pushes. From the Google C2DM page:
Also note that Google will periodically refresh the token in an
Update-Client-Auth
header. See this discussion on theandroid-c2dm
group for details.From my experience, I can't tell when or why Google chooses to refresh the token. It's happened to me as frequently as every day, and sometimes it's every week.