Use AppReceiptId app to authenticate user in Windows Store app?

I want to be able to use the AppReceiptId from the result of CurrentApp.GetAppReceiptAsync () and bind it to the username in my internal service to make sure that the user actually purchased the application.

I know that I should use CurrentAppSimulator instead of CurrentApp, but CurrentAppSimulator.GetAppReceiptAsync () always returns another random value for AppReceiptId. This makes testing difficult with my service.

Is there a way to make it always return the same value, except using hard coding only? I am worried that when I replace CurrentAppSimulator with CurrentApp and send it to the store, it will not behave as I expect. In the real world, AppReceiptId will never change, right?

The code I use to get AppReceiptId:

var receiptString = await CurrentAppSimulator.GetAppReceiptAsync(); XmlDocument doc = new XmlDocument(); doc.LoadXml(receiptString); var ReceiptNode = (from s in doc.ChildNodes where s.NodeName == "Receipt" select s).Single(); var AppReceiptNode = (from s in ReceiptNode.ChildNodes where s.NodeName == "AppReceipt" select s).Single(); var idNode = (from s in AppReceiptNode.Attributes where s.NodeName == "Id" select s).Single(); string id = idNode.NodeValue.ToString(); 

id will always be random Guid.

+4
source share
1 answer

CurrentApp.GetAppReceiptAsync (). Id is a unique identifier for the actual purchase. Although this technically represents a unique purchase made by a single Windows identifier, it does not constitute a user, and I do not think that there is any guarantee for the longevity of this identifier.

Would you be better off using the Windows Live SDK to track the actual user ID on different devices?

In any case, in order to answer your initial question, no, I do not believe that there is a way to make it return the same identifier all the time. The only logical place for this function would be in the WindowsStoreProxy.xml file, and I do not see anything in the scheme that will allow you to specify this information.

0
source

Source: https://habr.com/ru/post/1444475/


All Articles