Restful response error:无效的api密钥

时间:2016-02-10 05:48:40

标签: api rest meteor restful-authentication api-key

我是流星中宁静的api的新手。我从流星厨师处获取代码,以了解流星中安静api的工作情况。

以下是链接:The Meteor Chef

每次收到响应时,我都会在 POSTMAN 上运行应用程序无效的api密钥error:401

connection: function( request ) {
    var getRequestContents = API.utility.getRequestContents( request ),
        apiKey             = getRequestContents.api_key,
        validUser          = API.authentication( apiKey );
        console.log(getRequestContents);
    if ( validUser ) {
      // Now that we've validated our user, we make sure to scrap their API key
      // from the data we received. Next, we return a new object containing our
      // user's ID along with the rest of the data they sent.
      delete getRequestContents.api_key;
      return { owner: validUser, data: getRequestContents };
    } else {
      return { error: 401, message: "Invalid API key." };
    }
  },

我在服务器端使用此服务并从else语句中获取此错误。即使在console.log之后,if语句也不显示任何值。它只在服务器上显示为null。

0 个答案:

没有答案