Search code examples
uwpwin-universal-appwns

Multiple WNS access_token for a single device single App?


I have a App running on one single Windows device. While authenticating it with WNS, I get an access_token in the response.

Is it possible to make a request for more than one access_token? Will it invalidate the previously generated access_tokens for the same App same device? i.e For an App on a single device, can we have multiple access_tokens supported?


Solution

  • Is it possible to make a request for more than one access_token?

    No, one authentication request will just return one access_token. But we can send multiple authentication requests to obtain multiple access_tokens.

    Will it invalidate the previously generated access_tokens for the same App same device?

    No, access_tokens are independent, it won't be invalidated until it has expired.


    I'm not sure why you need multiple access_tokens supported. As Windows Push Notification Services (WNS) overview described:

    The access token described above can be reused for multiple notification requests; the cloud server is not required to request a new access token for every notification. If the access token has expired, the notification request will return an error. We recommended that you do not try to re-send your notification more than once if the access token is rejected. If you encounter this error, you will need to request a new access token and resend the notification.

    So for one channel URI, we don't need multiple access_tokens.

    However, if your app want to send push notifications to multiple apps, you need multiple access_tokens.

    An access token only allows a cloud service to send notifications to the single app for which the token was created. One access token cannot be used to send notifications across multiple apps. Therefore, if your cloud service supports multiple apps, it must provide the correct access token for the app when pushing a notification to each channel URI.

    For this scenario, you need request multiple access_tokens with each client_id and client_secret of multiple apps.