We need to get WNS (windows notification service) access token from our WNS secrets. This access token is required to send the notifications. This is just a simple POST request taken from the quickstart tutorial.
Details
- Reviewers
kamil tomek - Commits
- rCOMMd91f5d96ab3e: [keyserver] Get WNS authorization tokens
Run the new function and check if the acces token is properly returned. Modify the returned 'expires_in' value to a smaller one and check if the token is requested again.
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
I can't plan changes before the CI passes but I forgot to switch to node-fetch so I'm removing the reviewers for now.
keyserver/src/push/providers.js | ||
---|---|---|
130 | This is to handle an edge case when the token is near expiring and we preemptively refresh it in case of longer network latency etc. Inspired by the readme in this library (I didn't add it as a dependency because it didn't seem worth just to handle this one case of oauth). |
keyserver/src/push/providers.js | ||
---|---|---|
130 | For how long a new token lives? Should we make this duration as long as a request timeout? | |
135 | When are we going to extend this token lifetime? I guess if we return a token that has just 301ms left we don't have too much time to act. | |
138–141 | Should we include a note about this in our docs? Do we store this file in 1Password? | |
160 | Can we add a little more explanation to this error? |
keyserver/src/push/providers.js | ||
---|---|---|
154–157 | In the guide Content-Type header is set - is there a reason to not do that? |
Extended the duration of the token to 10s so we have more time to act. All of the tokens I had gotten from WNS previously, had 1h expiry time so it's still a small portion of the expiry time. Added better error explanation.
keyserver/src/push/providers.js | ||
---|---|---|
138–141 | I didn't add any new docs when adding web notifs, but if we have any official place for these I can definitely added them. There's a bit more info in the ENG-3562. The values themselves are stored in the 1Password. | |
154–157 | It should be set automatically because we are using URLSearchParams docs |