Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

try to refresh accesstoken on 401

  • Loading branch information...
1 parent 91b3418 commit eea8136cfc612e619eac3aeead4ba5bd46508e1d @tjanczuk committed
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/wns.js
6 lib/wns.js
@@ -273,6 +273,12 @@ var sendNotificationNow = function (context) {
// empty
+ else if (res.statusCode === 401 && !context.newAccessToken) {

should this not be happening anyway (even if there is not callback for e.g.)?

also - should a one-time retry be started in this case?

@tjanczuk Owner

I try to obtain a new access token in two situations:

  • the user did not provide options.accessToken when calling a sendXYZ method,
  • the user provided an expired options.accessToken when calling a sendXYZ method (which is represented by the !context.newAccessToken check above).

I am not sure we need to provide a retry for obtaining an access token (i.e. handle a situation when obtaining access token does not succeed on first try.

oh sorry I got lost in the flow (missing feature - expand file around the change to get proper context)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ // accessToken may have expired - try once to obtain a new one
+ obtainAccessToken(context);
+ }
else {
// failure

0 comments on commit eea8136

Please sign in to comment.
Something went wrong with that request. Please try again.