77
88
99class Apps (object ):
10- licenses = None #: :class:`dict` Account licenses
10+ licenses = None #: :class:`dict` Accounts' package licenses
1111
1212 def __init__ (self , * args , ** kwargs ):
1313 super (Apps , self ).__init__ (* args , ** kwargs )
@@ -57,9 +57,12 @@ def get_product_info(self, apps=[], packages=[], timeout=15):
5757 'packages': {123: {...}, ...}
5858 }
5959
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:
6366
6467 .. code:: python
6568
@@ -68,9 +71,21 @@ def get_product_info(self, apps=[], packages=[], timeout=15):
6871 if result['apps'][123]['_missing_token']:
6972 tokens = client.get_access_token(apps=[123])
7073
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+ }])
7489 """
7590 if not apps and not packages :
7691 return
@@ -107,7 +122,7 @@ def get_product_info(self, apps=[], packages=[], timeout=15):
107122 data ['apps' ][app .appid ] = vdf .loads (app .buffer [:- 1 ].decode ('utf-8' , 'replace' ))['appinfo' ]
108123 data ['apps' ][app .appid ]['_missing_token' ] = app .missing_token
109124 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 ), {})
111126 data ['packages' ][pkg .packageid ]['_missing_token' ] = pkg .missing_token
112127
113128 if not chunk .response_pending :
0 commit comments