snobu / destreamer

Save Microsoft Stream videos for offline enjoyment.
MIT License
2.37k stars 438 forks source link

Introduce token cache #22

Closed snobu closed 4 years ago

snobu commented 4 years ago

We need a token cache that:

This will dramatically improve the user experience since within the span of one hour (Azure AD issues tokens with 1-hour lifetime) users can download videos without having to log back in.

Decode sample:

import * as jwt_decode from 'jwt-decode';

const token = 'eyJ0eXAi...';
const decoded = jwt_decode(token);

let now = Math.floor(Date.now() / 1000);
let exp = decoded['exp'];
let timeLeft = exp - now; // seconds

Stretch goal:

Implementation in progress. See tokencache branch for status.

lukaarma commented 4 years ago

It's working great, the only issue we may have is if the token expires mid-download but for that there is already #43

snobu commented 4 years ago

Closing since token cache has been implemented. Tracking /refreshtoken implementation via https://github.com/snobu/destreamer/issues/43