[UWP]“访问令牌” WNS的有效性 [英] [UWP]"Access Token" validity of WNS

查看:66
本文介绍了[UWP]“访问令牌” WNS的有效性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在开发一项需要向Windows设备发送推送通知的服务。我按照以下步骤操作:https://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx" 请求
并接收访问令牌"。



当我的服务请求access_token时,  我看到WNS还发送  expires_in
以及  access_token   ;和  token_typ 元素
如下。但是,上述文档没有谈及  expires_in。


{

  " token_type":" bearer",

   ""access_token":" xxxxxxxxxxxxxxxxxxxx .................",&b $ b  " expires_in":86400

}



所以,我有以下与access_token和expires_in相关的问题:


  1. WNS会一直发送 expires_in 吗?如果是,我可以依赖 expires_in
    来定期刷新access_token吗?刷新,我的意思是在86,400秒之前再次发送访问令牌请求。
  2. 是否有其他方式在其他地方定义刷新access_token?
  3. 如果没有办法刷新访问令牌,正在接收401发送给WNS的通知请求的响应,唯一的wa是否知道access_token已过期?

解决方案

< blockquote>


嗨汉克,



>>
WNS总是会发送expires_in吗?如果是这样,我可以依赖expires_in来定期刷新access_token吗?通过刷新,我的意思是在86,400秒之前再次发送
一个访问令牌请求。



通常,它总是发送它。根据文档,

Windows推送通知服务(WNS)概述,推荐的方式是
"应用程序每次请求新频道在URI更改时运行并更新其服务。"
这意味着每次创建新频道时都需要发送访问令牌请求。



>>是否有其他方式定义刷新access_token?



如果频道网址未更改或过期,您可以尝试发送访问令牌。但我仍然建议您最好按照该文档申请新的
频道。



>>
如果无法刷新访问令牌,是否收到对发送给WNS的通知请求的401响应,那么知道
访问令牌已过期的唯一方法是什么?



根据文件中的
HTTP响应代码,是的,它是。





最好的问候,



罗伊


I'm developing a service which needs to send push notifications to Windows Devices. I've followed the steps at https://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx under "Requesting and receiving an access token".

When my service requests for an access_token, I see that WNS also sends expires_in in addition to access_token and token_typelements as below. But, the above documentation doesn't talk about expires_in.

{
    "token_type": "bearer",
    "access_token": "xxxxxxxxxxxxxxxxxxxx.................",
    "expires_in": 86400
}

So, I have the below questions related to access_token and expires_in :

  1. Would WNS always send expires_in ? If so, can I depend on expires_in to periodically refresh the access_token ? By refresh, I mean sending an Access Token Request again before 86,400 seconds.
  2. Is there any other way defined elsewhere to refresh the access_token ?
  3. If there is no way to refresh the access token, is receiving a 401 response to a Notification request sent to WNS, the only way to know that access_token has expired ?

解决方案

Hi Hank,

>> Would WNS always send expires_in ? If so, can I depend on expires_in to periodically refresh the access_token ? By refresh, I mean sending an Access Token Request again before 86,400 seconds.

Generally, it always send it. According to the document, Windows Push Notification Services (WNS) overview, the recommended way is that "the app requests a new channel every time it runs and updates its service when the URI changes." That means you will need to send an Access Token Request every time the new channel is created.

>> Is there any other way defined elsewhere to refresh the access_token ?

If the channel URL is not changed or expired, you could try to send an Access Token. But I still suggest that you’d better follow the document and request a new channel instead.

>> If there is no way to refresh the access token, is receiving a 401 response to a Notification request sent to WNS, the only way to know that access token has expired ?

According to HTTP response code from the document, yes, it is.

Best regards,

Roy


这篇关于[UWP]“访问令牌” WNS的有效性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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