Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Button for owned/playable games #263

Open

Description

@shokarta

Hello,

please add a button so iwe can filter all games which we own and are playable...
After some time buying stuff and having lots of games its not that simple to see them so i can properly choose what to play.

this can be achieved by:
POST to https://collections.mp.microsoft.com/v8.0/collections/b2bLicensePreview
HEADERS:
"Content-Type: application/json; charset=utf-8",
"Authorization: XBL3.0 x=" . json_decode(file_get_contents($GLOBALS["file"]["webToken"]), true)["DisplayClaims"]["xui"][0]["uhs"] . ";" . json_decode(file_get_contents($GLOBALS["file"]["webToken"]), true)["Token"],
"Host: collections.mp.microsoft.com",
"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 Edg/150.0.0.0" // not sure if useragent is needed here
POST DATA:
"maxPageSize" => 200,
"excludeDuplicated" => true,
"expandSatisfyingItems" => true,
"market" => "neutral", // keep neutral here so it does mnot filter games i bought in US/DE/etc
"entitlementFilters" => ["*:Game"]

this returns only first 200 games... if i wish to see next page with another 200 items, then i need to call it exactly same again, plus into post data i need to add "continuationToken" exactly as received in previous responce from this endpoint (if this field "continuationToken" is not present in responce, then no next page is available)

  • so far i havent get into any item form this list which would be JUST purchased but not streamable, but probably worth (at least to future versions) make aditional call of those IDs to check if all are perfectly playable

Activity

  1. added
    enhancement
    on Aug 4, 2026
  2. Geocld commented on Aug 4, 2026

    @Geocld
    Owner

    Hi, bro, I test the b2bLicensePreview API, and request successfully. But I still get the empty data(My account has purchase game), Are you fetch the same API? You can provide some response example for me, thks.

  3. shokarta commented on Aug 4, 2026

    @shokarta
    Author

    sure... sorry i forgot that for this you need to use xsts token where RelyingParty value is "http://mp.microsoft.com" (also I think if you change your webtoken relying party from http://xboxlive.com to http://mp.microsoft.com then all works for your app normally, you will be able to see all games from xbox etc, plus you shall be able to see purchased items for your account == this is worth trying, better then creating one more token if not needed), so all overall request (in php simplified for you to see the logic) i use:

    		// TOKEN for purchased ITEMS - START
    		$header = [
    			"Content-Type: application/json",
    			"Cache-Control: no-cache",
    			"x-xbl-contract-version: 1",
    			"Origin: https://www.xbox.com",
    			"Referer: https://www.xbox.com/",
    			"Accept: */*",
    			"ms-cv: 0",
    			"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"		// probably not needed
    		];
    		
    		$post = [
    			"Properties" => [
    				"SandboxId" => "RETAIL",
    				"UserTokens" => [MSAL_Token]			// standard MSAL token, same as you do :)
    			],
    			"RelyingParty" => "http://mp.microsoft.com",		// i think MP stands for Microsoft Purcahse (some lame repos conside this as "MultiPlayer" but its wrong
    			"TokenType" => "JWT"
    		];
    
    		$ch = curl_init();
    		
    		curl_setopt($ch, CURLOPT_URL, $url);
    		curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    		curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post, JSON_UNESCAPED_SLASHES));
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		
    		$response = curl_exec($ch);
    		$error = curl_error($ch);
    		
    		curl_close($ch);
    				
    		$MP_Token = $response;		// delcare MP_Token
    		// TOKEN for purchased ITEMS - END
    		
    		
    		
    		
    		
    		// LIST of purchased ITEMS - START
    		$header = [https://learn.microsoft.com/en-us/gaming/gdk/docs/store/commerce/service-to-service/microsoft-store-apis/xstore-v8-query-for-products?view=gdk-2604#response-example
    			"Content-Type: application/json; charset=utf-8",
    			"Authorization: XBL3.0 x=" . $MP_Token["DisplayClaims"]["xui"][0]["uhs"] . ";" . $MP_Token["Token"],
    			"Host: collections.mp.microsoft.com",
    			"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 Edg/150.0.0.0"		// probably not needed
    		];
    		$post = [
    			"maxPageSize" => 200,			// this is maximum unfortunatelly
    			"excludeDuplicated" => true,
    			"expandSatisfyingItems" => true,
    			"market" => "neutral",
    			"entitlementFilters" => ["*:Game", "*:Durable", "*:Consumable", "*:UnmanagedConsumable"]			// Game / Application / Durable / Consumable / UnmanagedConsumable / Pass		https://learn.microsoft.com/en-us/gaming/gdk/docs/store/commerce/service-to-service/microsoft-store-apis/xstore-v8-query-for-products?view=gdk-2604#product-type-values-and-meaning
    		];
    
    		do {
    			if ($continuationToken !== null) { $post["continuationToken"] = $continuationToken; }		// include continuationToken in postData from previous call if exist (declaring bellow)
    
    			$ch = curl_init();
    				
    			curl_setopt($ch, CURLOPT_URL, "https://collections.mp.microsoft.com/v8.0/collections/b2bLicensePreview");
    			curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post, JSON_UNESCAPED_SLASHES));
    			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    				
    			$response = curl_exec($ch);
    			$error = curl_error($ch);
    			
    			curl_close($ch);
    			
    			// the responce look like this: https://learn.microsoft.com/en-us/gaming/gdk/docs/store/commerce/service-to-service/microsoft-store-apis/xstore-v8-query-for-products?view=gdk-2604#response-example
    			
    			$continuationToken = $array["continuationToken"] ?? null;			// declare continuationToken (if exist) from reply so we can use it for next page call
    		
    		} while ($continuationToken !== null);
    		// LIST of purchased ITEMS - END
    

    in generaly, docu is very simple and clear: https://learn.microsoft.com/en-us/gaming/gdk/docs/store/commerce/service-to-service/microsoft-store-apis/xstore-v8-query-for-products?view=gdk-2604

  4. added
    need research
    on Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneed research

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions