Install and cloud-subscribe a package when after agreeing to the license

CURA-6983
This commit is contained in:
Nino van Hooff 2020-01-10 14:20:58 +01:00
parent 1cf3cd8228
commit 35695e5ab6
5 changed files with 51 additions and 9 deletions

View file

@ -1,5 +1,6 @@
from PyQt5.QtNetwork import QNetworkRequest
from UM.Logger import Logger
from UM.TaskManagement.HttpRequestScope import DefaultUserAgentScope
from cura.API import Account
from cura.CuraApplication import CuraApplication
@ -14,6 +15,10 @@ class UltimakerCloudScope(DefaultUserAgentScope):
def request_hook(self, request: QNetworkRequest):
super().request_hook(request)
token = self._account.accessToken
if not self._account.isLoggedIn or token is None:
Logger.warning("Cannot add authorization to Cloud Api request")
return
header_dict = {
"Authorization": "Bearer {}".format(token)
}