7
7
8
8
9
9
class Apps (object ):
10
- licenses = None #: :class:`dict` Account licenses
10
+ licenses = None #: :class:`dict` Accounts' package licenses
11
11
12
12
def __init__ (self , * args , ** kwargs ):
13
13
super (Apps , self ).__init__ (* args , ** kwargs )
@@ -57,9 +57,12 @@ def get_product_info(self, apps=[], packages=[], timeout=15):
57
57
'packages': {123: {...}, ...}
58
58
}
59
59
60
- When a token is needed to access the full info (e.g. branches and depots) the ``_missing_token``
61
- will be set to ``True``. The token can be obtained by calling :meth:`get_access_tokens` if
62
- the account has a license.
60
+ Access token is needed to access full information for certain apps, and also package info.
61
+ Each app and package has its' own access token.
62
+ If a token is required then ``_missing_token=True`` in the response.
63
+
64
+ App access tokens are obtained by calling :meth:`get_access_tokens`, and are returned only
65
+ when the account has a license for the specified app. Example code:
63
66
64
67
.. code:: python
65
68
@@ -68,9 +71,21 @@ def get_product_info(self, apps=[], packages=[], timeout=15):
68
71
if result['apps'][123]['_missing_token']:
69
72
tokens = client.get_access_token(apps=[123])
70
73
71
- result = client.get_product_info(apps={'appid': 123,
72
- 'access_token': tokens['apps'][123]
73
- })
74
+ result = client.get_product_info(apps=[{'appid': 123,
75
+ 'access_token': tokens['apps'][123]
76
+ }])
77
+
78
+ .. note::
79
+ It is best to just request access token for all apps, before sending a product info
80
+ request.
81
+
82
+ Package tokens are located in the account license list. See :attr:`.licenses`
83
+
84
+ .. code:: python
85
+
86
+ result = client.get_product_info(packages=[{'packageid': 123,
87
+ 'access_token': client.licenses[123].access_token,
88
+ }])
74
89
"""
75
90
if not apps and not packages :
76
91
return
@@ -107,7 +122,7 @@ def get_product_info(self, apps=[], packages=[], timeout=15):
107
122
data ['apps' ][app .appid ] = vdf .loads (app .buffer [:- 1 ].decode ('utf-8' , 'replace' ))['appinfo' ]
108
123
data ['apps' ][app .appid ]['_missing_token' ] = app .missing_token
109
124
for pkg in chunk .packages :
110
- data ['packages' ][pkg .packageid ] = vdf .binary_loads (pkg .buffer [4 :])[ str (pkg .packageid )]
125
+ data ['packages' ][pkg .packageid ] = vdf .binary_loads (pkg .buffer [4 :]). get ( str (pkg .packageid ), {})
111
126
data ['packages' ][pkg .packageid ]['_missing_token' ] = pkg .missing_token
112
127
113
128
if not chunk .response_pending :
0 commit comments