ThomasPe / MS-Store-API

Trying to figure out the Microsoft Store API
MIT License
64 stars 4 forks source link

Generate direct downloadable link #9

Open Howard20181 opened 2 years ago

Howard20181 commented 2 years ago

Any way to get package download links from the catalogId?

Howard20181 commented 2 years ago

Curious about how store.rg-adguard.net works.

Caesar008 commented 2 years ago

Not sure, but maybe this may slightly help? What I was able to find about project it is able to find and download Windows ISOs from MS download sides. But as I'm not much good in reading batch scripts I'm not sure if it may help or mot. At least there was, in several batch or php files, some POST queries to MS sites to return ISO download link. Maybe someone who has more time and knowledge than me can bring some light to it? https://github.com/hitdn110/docs/tree/3bcdfdeac30aabec6049997d5de90e15ea8a6d45/windows/uupdl-master

CE1CECL commented 2 years ago

Would like to have this too!

Caesar008 commented 2 years ago

Curious about how store.rg-adguard.net works.

Looks it rely on WuCategoryID returned by https://storeedgefd.dsx.mp.microsoft.com/v9.0/pages/searchResults

Example result (only related line) from query to search for DisneyPlus

"FulfillmentData": "{\"ProductId\":\"9NXQXXLFST89\",\"WuBundleId\":\"7f0fccd4-7e32-4973-9158-69f0072bd051\",\"WuCategoryId\":\"22e0ce7f-427a-40fa-bfa6-0de7b8554840\",\"PackageFamilyName\":\"Disney.37853FC22B2CE_6rarf9sa4v8jt\",\"SkuId\":\"0010\",\"Content\":null,\"PackageFeatures\":null}",

When result does not return WuCategoryID, for example GIMP, it is not able to find any download link. Unfortunately I did not find way how to get links by WuCategoryID yet.

Howard20181 commented 2 years ago

https://github.com/LSPosed/MagiskOnWSALocal/blob/main/scripts/generateWSALinks.py

CE1CECL commented 2 years ago

Found something @Caesar008 @Howard20181 https://github.com/StoreDev/StoreLib

Caesar008 commented 2 years ago

Found something @Caesar008 @Howard20181 https://github.com/StoreDev/StoreLib

Great, this looks very promising and looks as what we are looking for. I can see it uses same xml files as in https://github.com/LSPosed/MagiskOnWSALocal/blob/main/scripts/generateWSALinks.py found by Howard and does practically same things, but looks more robust/complex. It also does similar queries to URIs I was testing yesterday based on that .py script. It uses APIs v7, so maybe it is bit older, as it looks v9 is available. Once I will have more free time (people at work/customers gets crazy after summer vacations) I will play with this and will check if it is capable to also find/generate links for apps without category ID in our results and which store.rg-adguard is not able to find (e.g. GIMP - XPDM27W10192Q0) and how it handles msix/msixbundle extension.

Caesar008 commented 2 years ago

Looks StoreLib has problems with some apps as GIMP as well. It also does not return file extension, or I did not find where it is stored.

Caesar008 commented 2 years ago

So for apps with WUCategoryID it works in this way (example on Speedtest by Ookla):

First get JSON from MS using GET on link https://storeedgefd.dsx.mp.microsoft.com/v9.0/products/9NBLGGH4Z1JC?market=US&locale=en-us&deviceFamily=Windows.Desktop

between "products/" and "?market" is application ID - you can get it from link to MS store app (by search with google for example if no MS store app is available to get link to app)

Next step is to obtain encrypted data from MS which are required in following step. It is done by sending POST with XML file as this: https://github.com/LSPosed/MagiskOnWSALocal/blob/main/xml/GetCookie.xml and POST is sent to https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx You will receive XML where you search for node "EncryptedData". its content is used in next step.

Another POST is sent to https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx it contains new XML which is created from https://github.com/LSPosed/MagiskOnWSALocal/blob/main/xml/WUIDRequest.xml In this XML you need to fill content of EncryptedData node from previous request into node "EncryptedData". Then you need to fill WUCategoryID, you obtained in first step, to node FilterAppCategoryIds/CategoryIdentifier/Id And requred ring in "DeviceAttributes" tag, data "BranchReadinessLevel=CB;CurrentBranch=rs_prerelease;OEMModel=Virtual Machine;FlightRing={ring here without bracets}; ...". Accepts "retail", "RP", "WIS" and "WIF".

You will receive another XML where is list of appx/appxbundle/msix/msixbundle files. You will need data from "FileName" attribute inside "File" node to know what file extension it has (appx/appxbundle/msix/msixbundle). Then you need to get "RevisonNumber" and "UpdateId" attributes from "UpdateIdentity" node. Also search for "SecuredFragment" node near "UpdateIdentity" node - it indicates that URL for file is available.

And final step which requires another XML file in POST data to https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured: https://github.com/LSPosed/MagiskOnWSALocal/blob/main/xml/FE3FileUrl.xml In this file you need to fill data in "RevisionNumber" and "UpdateID" nodes and again select correct ring in "DeviceAttributes" tag, dataBranchReadinessLevel=CB;CurrentBranch=rs_prerelease;OEMModel=Virtual Machine;FlightRing={ring here without bracets}; ...". Accepts "retail", "RP", "WIS" and "WIF".

After all of this you finally receive XML response with generated download link which is inside "Url" tag.

But it works only for apps which in first step return JSON where WUCategoryID is specified. Still do not know how to get link for apps without WUCategoryID, for example GIMP, AppID XPDM27W10192Q0

youxiaohou commented 2 years ago

@Caesar008 You can use https://storeedgefd.dsx.mp.microsoft.com/v9.0/packageManifests/XPDM27W10192Q0?Market=US to get the installer for the app start with x which is not appx/msix package

Caesar008 commented 2 years ago

@Caesar008 You can use https://storeedgefd.dsx.mp.microsoft.com/v9.0/packageManifests/XPDM27W10192Q0?Market=US to get the installer for the app start with x which is not appx/msix package

Thanks, I didn't noticed URL there when searching for this kind of apps when testing endpoints in this repo. Get to https://storeedgefd.dsx.mp.microsoft.com/v9.0/packageManifests/XPDM27W10192Q0 will receive JSON, search for "InstallerUrl"

FranzFischer78 commented 1 year ago

Would this also work with xbox games? As the app id starts with a 9 instead of an X but doesn't seem to return anything?

CE1CECL commented 1 year ago

Would this also work with xbox games? As the app id starts with a 9 instead of an X but doesn't seem to return anything?

https://github.com/skydevil88/XboxDownload ??

FranzFischer78 commented 1 year ago

@CE1CECL Very suspicious to me https://github.com/skydevil88/XboxDownload/blob/master/XboxDownload/ClassMbr.cs ???

What does this class have to do with msstore stuff?

Caesar008 commented 1 year ago

@CE1CECL Very suspicious to me https://github.com/skydevil88/XboxDownload/blob/master/XboxDownload/ClassMbr.cs ???

What does this class have to do with msstore stuff?

Probably nothing. It looks it reads and overwrites master boot record (file read/write offset 0, length 512) through kernel libraries.

CE1CECL commented 1 year ago

@CE1CECL Very suspicious to me https://github.com/skydevil88/XboxDownload/blob/master/XboxDownload/ClassMbr.cs ??? What does this class have to do with msstore stuff?

Probably nothing. It looks it reads and overwrites master boot record (file read/write offset 0, length 512) through kernel libraries.

There is also this website: https://xbox.skydevil.xyz/

RokeJulianLockhart commented 4 months ago

https://github.com/ThomasPe/MS-Store-API/issues/9#issue-1311148931

https://github.com/microsoft/winget-cli/issues/578#event-13383463152 might be noteworthy - I assume that there is now a publicly documented API for downloading specific .AppX and .MSIX packages from msstore, although not specific versions of them.

sheikhmishar commented 2 months ago

I need some help installing downloaded .vsix packages. I am successful in installing and launching the apps if I have internet connection. However, I live in a rural place, where internet connectivity is not that available. I have to work on some Air Gapped systems as well. Without internet, the apps don't launch for the first time. I went through the event log and found that it was searching for some license server

RokeJulianLockhart commented 2 months ago

https://github.com/ThomasPe/MS-Store-API/issues/9#issuecomment-2324193825

@sheikhmishar, I think that might be outside the purview of this issue, since you do have the installation file. Perhaps create a new issue (in lieu of not having GitHub Discussions enabled for this repository)?

pl4nty commented 1 month ago

The 1P client is public now, but it's C++. StoreLib might be easier to understand