英特尔XDK:Parse.com集成“未经授权" [英] Intel XDK : Parse.com integration "Unauthorized"

查看:70
本文介绍了英特尔XDK:Parse.com集成“未经授权"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Intel XDK还是陌生的,因此我尝试在该视频教程中制作一个非常简单的应用程序,例如:

I am very new to Intel XDK and i try to make a very simple app like this in that video tutorial: Using Services Datafeed in App Designer.

但是,我希望集成Parse.com中拥有的数据库,而不是Rotten Tomatoes的特定服务.为此,我遵循了此视频教程:集成新服务"

But instead of the specific service from Rotten Tomatoes i want to integrate a database i have in Parse.com. For that i followed this video tutorial: "Integrating a New Service"

"[https]://software.intel.com/zh-cn/html5/videos/integrating-a-new-service",

"[https]://software.intel.com/en-us/html5/videos/integrating-a-new-service",

,最后的答复是:未经授权" .

然后我只找到了.

Then i found only this answer which comes from Intel's HTML5 Development Forums. I did not get anything either with this. The response was again: "Unauthorized".

现在我感到困惑和失望,因为:

And now i am confused and disappointed because:

  1. 我找不到其他资源来帮助自己
  2. 我不想代替我去做别人,但是
  3. 没有完整的示例,应该如何学习?

我的代码现在与视频中的代码相似:集成新服务"

My code now is similar with this in video: "Integrating a New Service"

apiconfig.json

{
  "MyService": {
    "name": "The external service",
    "description": "A great API with an external service",
    "dashboardUrl": "https://parse.com",
    "auth": "key",
    "signature": "apiSecret"
  }
}

MyService.js

(function (credentials) {
  var exports = {};

  exports.ServiceObject = function(params) {
    var url = 'https://api.parse.com/1/classes/ServiceObject';
    params['apiKey'] = credentials.apiKey;
    url = url + '?' + $.param(params);
    return $.ajax({url: url, type: 'GET'});
  };

  return exports;
})

MyService.json

{
"endpoints": [
  {
    "name": "classes",
    "dashboardUrl": "https://parse.com/docs/rest",
    "methods": [
      {
        "MethodName": "ServiceObject",
        "Synopsis": "Show the entries",
        "parameters": [
          {
            "Name": "objectId",
            "Required": "N",
            "Default": "",
            "Type": "string",
            "Description": "The object ID"
          },
          {
            "Name": "text",
            "Required": "N",
            "Default": "",
            "Type": "string",
            "Description": "The text"
          }
        ]
      }
    ]
  }
]
}

有人可以帮助我更多吗?他以最佳方式思考.

Can someone help me more? In whatever way he thinks best.

谢谢大家

在回答以下问题后,我的问题解决了.

After the following answer, my problem solved.

" MyService.js "文件是:

(function (credentials) {
  var exports = {};

    exports.ServiceObject = function(params) {
    var url = 'https://api.parse.com/1/classes/ServiceObject';
    return $.ajax({
            url : url,
            headers : {
            'X-Parse-Application-Id' : credentials.apiKey,
            'X-Parse-REST-API-Key' : credentials.apiSecret
            }
        });
    };

  return exports;
})

@ user1736947 :您的答案简明扼要,正是我所需要的.当然,将来我会需要很多帮助,但是现在,由于您,我可以继续接受自我教育.非常感谢.

@ user1736947: Your answer was concise and precise, exactly what i needed. Certainly in the future I will need a lot of help, but for now I can go on my self-education thanks to you. Thank you very much.

推荐答案

对于不同的服务,接受身份验证密钥的方式是不同的.视频中的示例..rottentomatoes ..它接受键作为url参数,因此我们将键附加到url上并将其发送.但是,似乎parse想要标题中的键(根据)

The way the authentication keys are accepted is different for different services. The example in the video.. rottentomatoes.. it accepted keys as a url parameter, so we append the key to the url and send it. However, seems like parse wants the keys in the headers (according to this)

因此等效的ajax调用将类似于:

So the equivalent ajax call will be something like :

 exports.ServiceObject = function(params) {
   var url = 'https://api.parse.com/1/classes/ServiceObject';
   return $.ajax({
     url : url,
     headers : {
      'X-Parse-Application-Id' : credentials.apiKey,
      'X-Parse-REST-API-Key' : credentials.apiSecret
     }
  });

这可能无法解决所有问题,但它将使您超越授权问题.让我知道您是否能够通过这种方式重返课堂.要获取特定的行条目,请在URL后面附加params.objectID.

This might not fix everything but it will move you a step beyond the authorization issue. Let me know if you are able to retreive the class this way. To get a particular row entry, append the url with params.objectID.

此外,XDK服务选项卡具有类似于解析的服务... kinvey.它还允许您在线创建数据库并检索它.

Also, the XDK services tab has a parse-similar service ... kinvey. It also allows you to create a database online and retreive it.

这篇关于英特尔XDK:Parse.com集成“未经授权"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆