+ return self._REAL_TOKEN
+
+ @_TOKEN.setter
+ def _TOKEN(self, value):
+ self._REAL_TOKEN = value
+
+ expiry = traverse_obj(value, ({jwt_decode_hs256}, 'exp', {int_or_none}))
+ if not expiry:
+ raise ExtractorError('There was a problem with the auth token')
+ self._TOKEN_EXPIRY = expiry
+
+ def _perform_login(self, username, password):
+ login = self._download_json(
+ 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword', None,
+ 'Logging in', query=self._LOGIN_QUERY, headers=self._LOGIN_HEADERS, data=json.dumps({
+ 'returnSecureToken': True,
+ 'email': username,
+ 'password': password,
+ }, separators=(',', ':')).encode())
+ self._REFRESH_TOKEN = traverse_obj(login, ('refreshToken', {str}))
+ if not self._REFRESH_TOKEN:
+ self.report_warning('No refresh token was granted')
+ self._TOKEN = traverse_obj(login, ('idToken', {str}))
+
+ def _real_initialize(self):
+ if WrestleUniverseBaseIE._DEVICE_ID:
+ return
+
+ WrestleUniverseBaseIE._DEVICE_ID = self._configuration_arg('device_id', [None], ie_key='WrestleUniverse')[0]
+ if not WrestleUniverseBaseIE._DEVICE_ID:
+ WrestleUniverseBaseIE._DEVICE_ID = self.cache.load(self._NETRC_MACHINE, 'device_id')
+ if WrestleUniverseBaseIE._DEVICE_ID:
+ return
+ WrestleUniverseBaseIE._DEVICE_ID = str(uuid.uuid4())
+
+ self.cache.store(self._NETRC_MACHINE, 'device_id', WrestleUniverseBaseIE._DEVICE_ID)
+
+ def _refresh_token(self):
+ refresh = self._download_json(
+ 'https://securetoken.googleapis.com/v1/token', None, 'Refreshing token',
+ query=self._LOGIN_QUERY, data=urlencode_postdata({
+ 'grant_type': 'refresh_token',
+ 'refresh_token': self._REFRESH_TOKEN,
+ }), headers={
+ **self._LOGIN_HEADERS,
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ })
+ if traverse_obj(refresh, ('refresh_token', {str})):
+ self._REFRESH_TOKEN = refresh['refresh_token']
+ token = traverse_obj(refresh, 'access_token', 'id_token', expected_type=str)
+ if not token:
+ raise ExtractorError('No auth token returned from refresh request')
+ self._TOKEN = token