如何检索Microsoft Store ID密钥?

时间:2017-11-27 18:02:26

标签: uwp windows-store

我正在尝试学习如何检索Microsoft Store ID密钥。为此,我按照Microsoft在Windows Universal Samples中提供的示例进行了操作。我尝试使用Business to Business场景(场景7)。我已经发布了一个示例App并在Azure Active Directory中注册了该应用程序。问题是我不知道我应该在getCustomerCollectionsIdAsync / getCustomerPurchaseIdAsync函数中作为publisherUserId参数发送什么值。我尝试发送当前用户(客户电子邮件)的电子邮件,该电子邮件仅检索空结果(Microsoft Store ID密钥)。

 function getCustomerCollectionsId() {
    var token = getTokenFromAzureOAuthAsync().done(function (aadToken) {
        if (aadToken) {
            storeContext.getCustomerCollectionsIdAsync(aadToken, "***@hotmail.com")//"kim@example.com"
                .done(function (result) {
                    output.innerText = result;
                    if (!result) {
                        WinJS.log && WinJS.log("getCustomerCollectionsIdAsync failed.", "sample", "error");
                    }
                });
        }
    });
}

function getCustomerPurchaseId() {
    var token = getTokenFromAzureOAuthAsync().done(function (aadToken) {
        if (aadToken) {
            storeContext.getCustomerPurchaseIdAsync(aadToken, "***@hotmail.com")//"kim@example.com"
                .done(function (result) {
                    output.innerText = result;
                    if (!result) {
                        WinJS.log && WinJS.log("getCustomerPurchaseIdAsync failed.", "sample", "error");
                    }
                });
        }
    });
}

2 个答案:

答案 0 :(得分:0)

using Windows.Security.Authentication.Web;
...
string SID = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();

如果您处于开发阶段,则可以尝试此操作。如果您担心将应用程序提交存储以进行Facebook身份验证之类的操作,这将很有帮助。下面给出的是我从中获得的参考。希望这会有所帮助!

http://microsoft.github.io/winsdkfb/index.html

答案 1 :(得分:0)

我遇到了同样的问题,这是适合我的解决方案。

转到https://portal.azure.com,选择“ Azure Active Directory”,选择“应用程序注册”,然后在右侧面板中选择您的应用程序。然后选择清单以编辑清单。将以下字段设置为值:

"accessTokenAcceptedVersion": 1,
"identifierUris": [
    "https://onestore.microsoft.com",
    "https://onestore.microsoft.com/b2b/keys/create/collections",
    "https://onestore.microsoft.com/b2b/keys/create/purchase"
    ],
"signInAudience": "AzureADMyOrg",

并且您的获取令牌请求(https://login.microsoftonline.com/xxx/oauth2/token)的资源字段必须是确切的字符串“ https://onestore.microsoft.com/b2b/keys/create/collections”(注意,域部分是“ onestore.microsoft.com”)

ps: 找到此解决方案的方法:

  • 使用charles ssl代理通过storeContext.getCustomerCollectionsIdAsync api记录我的c#项目的请求。发现它发送的网址是“ https://collections.mp.microsoft.com/v7.0/beneficiaries/me/keys”,并且请求正文包含我发送给它的令牌。
  • 使用charles ssl代理记录正常运行的其他应用程序(例如“ Hotspot Shield”)的请求,尝试从中购买商品并取消。找到该URL的请求,然后下载请求正文和base64原始URL以解码其令牌的第二部分,发现“ aud”为“ {https://onestore.microsoft.com/b2b/keys/create/collections”,“ ver”为“ 1.0”。
  • 更改“应用程序注册”的配置,令牌获取代码以使结果令牌的版本为1.0,并将“ aud”更改为正确的版本。

我认为“ Azure Active Directory”是版本2的更新,但是“ Microsoft Store ID密钥”文档没有更新到该版本...

相关问题